Too many worlds leads to OOM

Started by ppparkje, September 06, 2012, 11:30:09 AM

Previous topic - Next topic

ppparkje

Hi

I have a fatal oom error.

After profiling and inspecting the app I finally guessed that is because of multiple worlds.

Actually, I made a lot of worlds in one app and it always crashed at generating new world.


so I made a test code like this



List<World> w = new ArrayList<World>();
for(int i=0; i<100; i++) {
System.out.println("world " + i);
w.add(new World());
}



It makes just 100 world, but when I execute it, it crashed with OOM around i=47

Is the World class consume that so much memory?

AGP

I'm sure Egon will respond, but never having profiled a jpct app I can guess that World probably does use a lot of memory. Why do you want to have so many World instances? I can think of a need for at the most two (one for everything and a second one for the sky box).

EgonOlsen

World uses memory in relation to Config.maxPolysVisible because each world contains a visibility list of that size plus an additional structure of the same size to store clipped polygons. Like AGP said, i'm not sure why one would need 100 worlds. However, if you think that this is needed, just increase the amount of memory available to the VM with -Xmx256m (or some other value).

ppparkje



I needed a number of separate worlds for some operations including clipping and thought maybe world consumes few memory


... And it's my mistake. :/ I have a lot of things to learn.


Thanks for your support.