Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

rbeatajane

macrumors newbie
Original poster
Mar 11, 2011
8
0
Hi


The function below is causing me memory leak. I dont know why.
I'm using dwDelay but its telling me dwDelay is never read.What mistake am i doing here.

Code:
-(uint8_t)timeoutThread
{
unsigned long int       dwDelay = 0;
some stmts;
while()
{
 stmts;
}
dwDelay = 1000; //memory leak(value stored to 'dwDelay' is never read)
}
 
Last edited:

robbieduncan

Moderator emeritus
Jul 24, 2002
25,611
893
Harrogate
I don't see how that will leak memory: dwDelay is a stack variable. It's not storing a pointer to something on the heap so at the end of the method it's storage will automatically be recovered from the stack. The analyser is correct though: that last statement has no point as the value can never be read.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.