a problem about 3ds loader & viewer

Questions regarding game mechanics and graphic programming should go here.

Moderators: Darobat, RecursiveS, Dante Shamest, Bugdude, Wizard

a problem about 3ds loader & viewer

Postby neru » Wed Mar 23, 2005 12:20 am

Hi,all.
I have downloaded a 3ds loader & viewer from
http://www.garagegames.com/index.php?se ... ew&qid=506

I found my used-ram become more and more when
I used it to load a .3ds file in my OpenGL project.
I think there may be something wrong with free store.
I do some changes about the class destructor , but
it's still the same.

Please help me. Thanks!
neru
 
Posts: 4
Joined: Mon Mar 14, 2005 8:42 am

Postby Animatronic » Wed Mar 23, 2005 7:52 am

well i went through his 3ds loader and counted 11 calls to new, without a single matching call to delete. Obveriously the guy has something against freeing up memory :D .

just go through his Object structure in the deconstructor mathcing all his nes's to a delete[] call, plus at the end of load() you need to delete[] path. Also you can tak out hie path = new char[80] in the constructor as its pointless.
Animatronic
 
Posts: 90
Joined: Wed Jun 23, 2004 9:08 pm

Postby neru » Wed Mar 23, 2005 9:07 am

you mean this deconstructur ?

Model_3DS::~Model_3DS()
{

}

I tried to changed it like this:
Model_3DS::~Model_3DS()
{
delete [] path;
delete [] Materials;
delete [] Objects;
}

But the used-ram is still growing.
The rest delete[] I have no idea how to put in the destructor.
neru
 
Posts: 4
Joined: Mon Mar 14, 2005 8:42 am

Postby Animatronic » Thu Mar 24, 2005 7:04 am

he does multiple calls to new for each object... so something like:

Code: Select all
Model_3DS::~Model_3DS()
{

   for(int i=0;i<numObjects;i++)
   {
      delete [] Objects[i].Vertexes;
      delete [] Objects[i].Normals;
      delete [] Objects[i].TexCoords;
      delete [] Objects[i].Faces;
      for(int j=0;j<numMatFaces;j++)
      {
         delete [] Objects[i].MatFaces[j].subFaces;
      }
      delete [] Objects[i].MatFaces;
   }


   delete [] Materials;
   delete [] Objects;
   delete [] path;

}


so no time to test it. :)
Animatronic
 
Posts: 90
Joined: Wed Jun 23, 2004 9:08 pm


Return to Games and Graphics

Who is online

Users browsing this forum: No registered users and 1 guest