Eclipse memory settings when getting “Java Heap Space” and “Out of Memory”

前端 未结 11 824
野的像风
野的像风 2020-11-27 13:06

When trying to launch and run a flex/java project in eclipse I kept getting a \"Out of Memory Exception\" and \"Java Heap Space\" using Eclipse, Tomcat and a JRE.

Wh

11条回答
  •  半阙折子戏
    2020-11-27 13:34

    If you see an out of memory, consider if that is plausible: Do you really need that much memory? If not (i.e. when you don't have huge objects and if you don't need to create millions of objects for some reason), chances are that you have a memory leak.

    In Java, this means that you're keeping a reference to an object somewhere even though you don't need it anymore. Common causes for this is forgetting to call close() on resources (files, DB connections, statements and result sets, etc.).

    If you suspect a memory leak, use a profiler to find which object occupies all the available memory.

提交回复
热议问题