thanks
if ( a == NULL )
{
int aSize = rand() + 1;
int bSize = rand() + 1;
int cSize = rand() + 1;
a = new char[aSize+1];
b = new char[bSize+1];
c = new char[cSize+1];
FillMemory( a, aSize, 'a' );
FillMemory( b, bSize, 'b' );
FillMemory( c, cSize, 'c' );
a[aSize] = '\0';
b[bSize] = '\0';
c[cSize] = '\0';
}
else
{
delete[] a;
delete[] b;
delete[] c;
a = NULL;
b = NULL;
c = NULL;
}
David Erbas-White
A TTimer does not involve threads at all.
Jonathan
> Hi, I am doing this and it leaks!
How do you know that it leaks?
> This bit of code gets called every second by a timer.
Are you getting an even number of timer elapses before you stop the timer?
If the timer elapses an odd number of times, the delete statements won't be
executed the final time, thus leaking memory.
Gambit
anyway, I was just investigating this lead.
> We think it leaks at 75%
But you haven't explained WHY you think that. What exactly makes you think
that a leak is occuring at all?
> Our applications has many timers and I made a seperate project
> with this window that does not leak outside my application but
> when I bring this window in my application it leeks.
What exactly does the window do? You need to provide more details.
> I don't understand why or where.
Neither can anyone else until you explain exactly what you are doing with
it.
> Maybee it has to do with a timer at 100 ms and another one ay 1000 ms.
That in itself will not cause leaks.
> maybee the code in the 100 ms has not completely finished
> processing and another 100 ms pulse has come in..
Even if it did, the second timer will not actually be triggered until the
first timer finishes processing the event that is already in progress.
Unless you are using threaded timers, then your timers are serialized.
Unless you are using a message-based timer (such as TTimer) and the second
timer is reentrant because the first timer processing is pumping the message
queue for new messages. Again, it is very hard to diagnose our problem
because you have not provided any details about what you are actually doing
in your code.
Gambit