OutOfMemoryError

Started by Uija, November 25, 2005, 02:41:44 PM

Previous topic - Next topic

Uija

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

Uija

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.

EgonOlsen

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:


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...

Uija

Hm something wierd.

I render 5 x 5 models

     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

Raven

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"

Uija

Thanks alot, that helped.

Anonymous

And the next:

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

Uija


Raven

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:

Raven

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"

Uija

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:

Raven

Cool screens!
Is that Michael Jackson there in the middle?  :lol:

Just kidding. What's your project about?

Uija

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.

EgonOlsen

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?

Uija

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.