Author Topic: OutOfMemoryError  (Read 7689 times)

Offline Uija

  • int
  • **
  • Posts: 52
    • View Profile
OutOfMemoryError
« on: November 25, 2005, 02:41:44 pm »
have a little test, where one md2 Model runs in circles.

I added a "Mob" Object to my system holding the object and a tick() function, where the animation and movement is done.
in my loop() I run through my List of Mobs and call .tick() on every mob.

I works perfectly until I add a 5th Mob to my list. While loading the Object3d with Loader.loadMd2() I get a:

Exception in thread "main" java.lang.OutOfMemoryError

when the engine is procressing the 5th Model while loading the animations.

Is there a way to stop this? Is md2 the wrong source to work with? I like them as there are alot to use in the net and I already have animations to use for running, idleing and fighting.

~Jens

Offline Uija

  • int
  • **
  • Posts: 52
    • View Profile
OutOfMemoryError
« Reply #1 on: November 25, 2005, 03:04:55 pm »
well, I can run 5 with -Xmx128M but I dunno if I may get other problems as soon as I want to have 100 mobs running around and need some trees and stuff.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11745
    • View Profile
    • http://www.jpct.net
OutOfMemoryError
« Reply #2 on: November 25, 2005, 03:28:32 pm »
If it's the same model (or maybe just with different textures), you can load it once and use cloneObject() in Object3D on it to create your additional instances. That will reuse the mesh and animation data. If the current state of the animation is different for all models, it's additionally required to clone the Mesh because otherwise a call to animate() on Object 1 will influence Object 2. So the idea is basically:

Code: [Select]

Object3D newAnimObj=oldAnimObj.cloneObject();
newAnimObj.setMesh(newAnimObj.getMesh().cloneMesh(true));


In addition, you may set Config.saveMemory=true.
For reference: Paradroidz runs with -Xmx256m and uses around 128m of this . It uses around 3100 Object3Ds which it holds in that memory all the time.
Keyframe animation, however, is expensive in terms of memory usage.

Edit: The current WIP of 1.09 already includes a change suggested by raft that strips some unused information from meshes that are used for animation only. I may add this change to Animation itself somehow. It should help too...

Offline Uija

  • int
  • **
  • Posts: 52
    • View Profile
OutOfMemoryError
« Reply #3 on: November 25, 2005, 06:55:57 pm »
Hm something wierd.

I render 5 x 5 models
Code: [Select]

      N

1x  x  x  x  o
2x  x  x  x  x
3x  x  x  x  x  C2
4x  x  x  x  x  
5x  x  x  x  x
                      C
      S

My Cam(C) looks with birdview with lookAT onto my mainobject (o)
My Problem is: I only see 2 rows (10 Objects)
As soon as I move nearer to my Objects (position C2) I begin to see the 3rd line but loose some of the first 2.

Is there a limit of models?
I moved them around over the place to verify if its a view-range-problem, but it seems not to be.
I can post some screens, if you need to :P
Code: [Select]

Offline Raven

  • int
  • **
  • Posts: 62
    • View Profile
    • http://www.vortex.is/raven
OutOfMemoryError
« Reply #4 on: November 25, 2005, 07:18:39 pm »
Hey Uija.

Yeah, there is a config of max polygons visible.
Try the following with a few different settings:

Config.maxPolysVisible = <numberofpolys>;

According to the JavaDocs, the default is 4096.
There's also a far / near setting somehwere (how far into the horizon is rendered), but it sounds more like you need to set the maxPolys.

EDIT: Btw, screenshots are always fun to look at :)

-Hrafn "Raven"

Offline Uija

  • int
  • **
  • Posts: 52
    • View Profile
OutOfMemoryError
« Reply #5 on: November 25, 2005, 07:29:23 pm »
Thanks alot, that helped.

Anonymous

  • Guest
OutOfMemoryError
« Reply #6 on: November 25, 2005, 08:36:54 pm »
And the next:

any idea, why I have a floortexture in Software and no texture in OpenGL Mode?

Offline Uija

  • int
  • **
  • Posts: 52
    • View Profile
OutOfMemoryError
« Reply #7 on: November 25, 2005, 08:37:41 pm »
hm, was logged out =(

Offline Raven

  • int
  • **
  • Posts: 62
    • View Profile
    • http://www.vortex.is/raven
OutOfMemoryError
« Reply #8 on: November 25, 2005, 08:49:00 pm »
Sorry, you got me there.
I still haven't figured out how to use textures (except when specifically assigned to an object, like with md2 models and such). I also haven't quite learned the difference between Soft/Hardware rendering, so this question is like the mother of all questions to me :lol:

Offline Raven

  • int
  • **
  • Posts: 62
    • View Profile
    • http://www.vortex.is/raven
OutOfMemoryError
« Reply #9 on: November 25, 2005, 08:53:56 pm »
Oh, wait.
Actually, I might have something you could test.

Is the size of the texture itself a number in the power of two?
I seem to recall reading that the OpenGL renderer can behave irradically if the textures aren't sized properly.

Such as 256x256 or 1024x1024.

-Hrafn "Raven"

Offline Uija

  • int
  • **
  • Posts: 52
    • View Profile
OutOfMemoryError
« Reply #10 on: November 25, 2005, 08:57:30 pm »
2 Screens:

Software:


OpenGL:


funny thing is: this only happens on my notebook (ATI) and not on my MainPC (NVidia)

Edit:
Screen from MainPC with OpenGL:

Offline Raven

  • int
  • **
  • Posts: 62
    • View Profile
    • http://www.vortex.is/raven
OutOfMemoryError
« Reply #11 on: November 25, 2005, 08:59:51 pm »
Cool screens!
Is that Michael Jackson there in the middle?  :lol:

Just kidding. What's your project about?

Offline Uija

  • int
  • **
  • Posts: 52
    • View Profile
OutOfMemoryError
« Reply #12 on: November 25, 2005, 09:04:40 pm »
Hmm, my goal is to have something like a mmo game.
I am heavily interrested into the server thing and the way how client and server work together.
I play those games for years now and partly hate the companies for their bad Networkcode or heavy Lag, when many people are doing something together.
Now I try to build this thing step by step myself until I find out, why all those games lag like hell :P If I don't find it out, perhaps I can sell my idea and knowledge *lol*.

The models are md2 files I found on planetquake.com. I use them because its alot easier for my to handle the basics first, with good looking mobs and less work.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11745
    • View Profile
    • http://www.jpct.net
OutOfMemoryError
« Reply #13 on: November 25, 2005, 11:23:10 pm »
Quote from: "Uija"

funny thing is: this only happens on my notebook (ATI) and not on my MainPC (NVidia)
Driver problem? Which card/driver version are you using? Can you provide me with a test case for that?

Offline Uija

  • int
  • **
  • Posts: 52
    • View Profile
OutOfMemoryError
« Reply #14 on: November 25, 2005, 11:45:59 pm »
Card is: Ati Mobile Radeon 9700

Driver... hmm, i am using the ati driver that were shipped with my acer notebook.

I just found out, that I can see the plane, when I comment out the shadow code.

@test: sure, just tell me what to du.