This site requires JavaScript, please enable it in your browser!
Greenfoot back
HeapSpace
HeapSpace wrote ...

2018/12/8

Greenfoot memory leak?

HeapSpace HeapSpace

2018/12/8

#
Trying to create a game, however I've run into the heap space issue because of too many actors. What I noticed when I reduced the amount of actors and ran it multiple times is that it's memory usage in taskmgr increases by the amount needed to run the program once every time you reset/run. In other words: Greenfoot will start at around 150-200MB usage, you run once, it adds 70MB. you reset, it adds 70 mb etc... So it never actually "resets", it merely starts the execution of your program on top of the one already running, but only displaying the newest one. This can't be intended, right? It's not intuitive or user friendly in any case. Might I suggest: Terminate execution and reclaim memory when a user clicks on reset or runs the code via the main class. Perhaps I overlooked something though.
davmac davmac

2018/12/8

#
Task manager just shows how much memory an application has allocated from the operating system, not how much it is actively using. Java uses "garbage collection" meaning that it doesn't free unused memory immediately and may continue to allocate memory from the OS that it doesn't strictly need. I'm pretty sure that's what you're seeing here. If you keep repeating the same process, you'll eventually see the memory use according to Task Manager level out or even drop back to somewhere near the original level.
You need to login to post a reply.