Why memory leaks occurs when using DataStore API on dev server (not tested in production)?

怎甘沉沦 提交于 2019-12-06 16:13:34

问题


Could guys please help me find what causes memory leak ? It drives me crazy :(((

I'm using GAE SDK 1.6.1. I created sample project with single servlet that contains following doGet method

protected void doGet(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws javax.servlet.ServletException, IOException
{
    {
        DatastoreService datastore = DatastoreServiceFactory.getDatastoreService();

        System.out.println();
        for (long i = 1; i <= 10000000; ++i)
        {
            Entity entity = new Entity("Visitor");
            entity.setProperty("name", "Name is " + i);
            entity.setProperty("value", "Value is " + i);
            Key key = datastore.put(entity);
            System.out.println(key.getId());
        }
    }
}

Call to this servlet fails with OutOfMemory exception because all temporary datastore objects remain in the memory.

Here is tree of incoming references to held object obtained using YourKit Java Profiler.

Does anybody know why? How can I avoid this? Is it GAE-specific bug or something in my development environment?

Thanks!!!


回答1:


I just found this thread where Ikai Lan (Google) says "The development server datastore stub is an in memory Map that is persisted to disk".

Perhaps it answers my question.



来源:https://stackoverflow.com/questions/8843975/why-memory-leaks-occurs-when-using-datastore-api-on-dev-server-not-tested-in-pr

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!