Welcome, Guest. Please login or register.

Login with username, password and session length

 
Advanced search

11991 Posts in 1587 Topics- by 3508 Members - Latest Member: NevilleKemp

26. May 2012, 06:36:10 pm
Xith3D CommunityGeneral CategorySupport (Moderator: Marvin Fröhlich)Question on memory
Pages: [1]
Print
Author Topic: Question on memory  (Read 134 times)
gbrinon
Just dropped in

Offline Offline

Posts: 24



View Profile
« on: 26. November 2011, 06:05:13 pm »

Hello,

I tried to make a little test :
Code:

public static void printRemainingMem()
{
   long totalMem = Runtime.getRuntime().totalMemory();
   long freeMem = Runtime.getRuntime().freeMemory();
   
   System.out.println("usedMem="+(totalMem - freeMem));

   return ;
}

@Override
protected void loopIteration( long gameTime, long frameTime, TimingMode tm )
{
   super.loopIteration(gameTime, frameTime, tm);

   RectBillboard test =  new RectBillboard(1, 1, "ressources/particle1.png");
   test = null;

   System.gc();
   GraphicsCore.printRemainingMem();
   
   return;
}

There seem to have a memory leak but i don't know how to remove this kind of object.
There's no problem to detach them but is there a method to delete "in a clean way" the instance ?


Thanks
Logged

Guillaume
HEMERA project on XITH3D
Marvin Fröhlich
Xith Lord
Administrator
Guru
*****
Offline Offline

Posts: 4381


May the 4th, be with you...


View Profile
« Reply #1 on: 27. November 2011, 11:50:55 am »

In this code fragment is no error. I guess, you forgot to properly detach it from the scenegraph or something.

What do you want to do with this rectangle?
Logged
gbrinon
Just dropped in

Offline Offline

Posts: 24



View Profile
« Reply #2 on: 28. November 2011, 08:58:00 am »

In fact, i realized that i could resolve my problems on JOPS by coding on my own a very light little (and easy to use) particle system on xith3d. I thought it was a good exercise.
The results are quite good for the moment and i'll soon be able to implement it in my little game but i have a problem. I made a stress test (1000 particles generated per second, for 2 hours) and a realized that there was a memory leak.
I read my code and i didn't found the problem, i detach the particles when they are dead, ...

I wrote the little test on my first post and i saw that when you instanciate a RectBillboard, don't attach it to anything, set the instance to null (so in theory the garbage collector should take care of this) then there is a memory leak.

I looked for a method of RectBillboard to "release" all the ressources but i didn't found it.
Logged

Guillaume
HEMERA project on XITH3D
Pages: [1]
Print
Jump to:  

Theme orange-lt created by panic