Advertisement

Memory leaks with large arrays...

Started by February 26, 2000 03:25 PM
0 comments, last by Great Milenko 24 years, 6 months ago
ok I''m implementing a file archive system like pak... I''m using class... basicly as long as the data in an entiery dosen''t get large then about 512k theres no problem(or maby there is and I''m not caching it)... basicly the data is being held as an unsigned char* hears some code.... bool CEntiery::Read(ifstream&){ ...//read in header for entiery m_data=new unsigned char[m_size]; ...//read in data } void CEntiery::Release(void){ ...//release other members if(m_data){ delete[]m_data; m_data=NULL; } the destructor for the class just calls Release() I''m not seeing anything wrong with the code, but after running the program several times the computer starts to run out of memory... Great Milenko

Words Of Wisdom:
"Never Stick A Pretzel In Your Butt It Might Break Off In There."


http://www.crosswinds.net/~milenko
http://www.crosswinds.net/~pirotech

The Great Milenko"Don't stick a pretzel up your ass, it might get stuck in there.""Computer Programming is findding the right wrench to hammer in the correct screw."
My guess is that your problem with memory lies elsewhere... Is your CEntiery class based on something else? In that case, did you make sure your destructor was virtual in the base class? You could make sure by placing a breakpoint in Release() and see if it gets called. Are you dynamically allocating memory somewhere else in your program and forgetting to release it?

I''m just throwing out stuff to look at, because there''s really not enough here to tell where your problem lies. Your code here looks fine to me, too. The first thing I''d do is put the breakpoint in Release() just to be sure it''s getting called. After that, I''d start looking elsewhere (assuming that''s not the problem).

Mark Fassett
Laughing Dragon Entertainment
http:\\www.laughing-dragon.com

Mark Fassett

Laughing Dragon Games

http://www.laughing-dragon.com

This topic is closed to new replies.

Advertisement