Link to home
Start Free TrialLog in
Avatar of Hardaway
Hardaway

asked on

Detected memory leaks!

I have written a program with VC++ v5.0

I have no problem on compile it and run it, but after I quit the program(normally), I found that something appear in the debug window.

It stated the following.....
Detected memory leaks!
Dumping objects ->
C:\myprogram(188) : {263} normal block at 0x007F4970, 16 bytes long.
...........

But in myprogram line no. 188, the statement is just "CRect *rect = new CRect;"

What's the problem in this line??
Avatar of Tommy Hui
Tommy Hui

Are you deleting the memory? It appears that you have not deleted the memory, which is why the runtime libraries are complaining.
ASKER CERTIFIED SOLUTION
Avatar of shaig
shaig
Flag of Afghanistan image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Hardaway

ASKER

I made a mistake in deallocating the memory, so that why I have
an error when I run the program.

But now I have another problem, just take a look on the source code first:

Object::myfunc()
{
    for (int i = 0; i < limit; i ++)
        BOject[i] = new CObject;
}

BObject is declare as ClassName *BObject[limit]
and I have delete [] *BObject

However,still "Detected memory leaks"


Yuo have deleted the array of pointers, but not the data that the pointers have pointed to.
you should add ( bofeor doing what you are right now ) a 'for'
that will delete the data itself - very simular to the allocations.