Author Topic: Too many worlds leads to OOM  (Read 1934 times)

Offline ppparkje

  • byte
  • *
  • Posts: 9
    • View Profile
Too many worlds leads to OOM
« on: September 06, 2012, 11:30:09 am »
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

Code: [Select]

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?
« Last Edit: September 06, 2012, 11:35:24 am by ppparkje »

Offline AGP

  • quad
  • ******
  • Posts: 1726
    • View Profile
Re: Too many worlds leads to OOM
« Reply #1 on: September 06, 2012, 07:32:59 pm »
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).

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Too many worlds leads to OOM
« Reply #2 on: September 06, 2012, 08:18:45 pm »
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).

Offline ppparkje

  • byte
  • *
  • Posts: 9
    • View Profile
Re: Too many worlds leads to OOM
« Reply #3 on: September 07, 2012, 02:41:31 am »


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.