> Hi Harry,

I don't want to get into a big discussion about this, especially since I'm 
definitely no expert on the subject, but ...

> Thanks for the response.  I agree that in a simple case like this it might
> be possible to detect a leak although I'm skeptical that Poser does
> this.  In general, however, this type of determination is not
> possible.  For example, consider
>
> fred = MemPtrNew(100);
> SomeFunc(fred);
> fred = MemPrtrNew(100);

> Is it still a leak?

If the memory management in Poser is done by reference counting, then memory 
accesses in the code of SomeFunc() would also be subject to the same 
reference counting.  Hence, if SomeFunc() didn't assign fred to some other 
(non-stack) variable, then the reference count would be 1 when it was called 
and still 1 when it returned, so Poser could catch the memory leak.

Similarly, if SomeFunc() HAD assigned it to some other variable then the 
reference count would be greater than one, hence Poser could tell that the 
second assignment in the above code still left one reference to the 100 bytes 
and was hence not a leak.

As I say, I have no idea what scheme Poser uses to detect leaks, but this 
kind of approach can certainly do it. 

H.

-- 
For information on using the Palm Developer Forums, or to unsubscribe, please see 
http://www.palmos.com/dev/tech/support/forums/

Reply via email to