Re: leaks in my app
Re: leaks in my app
- Subject: Re: leaks in my app
- From: Fred Leboucher <email@hidden>
- Date: Fri, 11 Jul 2008 08:26:24 +0200
Sandeep,
As far as I'm concerned, Instruments with ObjectAlloc/Leaks helped me a lot. SO
you could go on using that, it's perfectly fine.
Regarding your specific problem, you should make the difference between leaks
and memory increase: A leak is an object that is not released but not referenced
anywhere in the application. Thus, it will never be released and will leak. As
such, leaks will increase memory usage. But it's only the only thing. An example
of that is autoreleased objects. Say you have an object that is alloc'd and
init'd, then autoreleased (which is the case with most '+' methods). This object
will then only be referenced by the autorelease pool, as long as you do not
release the pool. WHen the pool is released, the object will be released too,
and won't be considered a leak. But still, it will consume memory, even though
the object is not needed anymore.
To check/fix that, you should use the ObjectAlloc part. The objects are
classified by type, and the bar graph on the far right shows the proportion of
objects that are still alive (including those only in the autorelease pool)
against the whole bunch that was alloc'd at one time or another. If you see a
big proportion of objects being alive that shouldn't be, that is it ! And for
the fix, it's quite simple: if you make some heavy allocating/releasing of
memory in a method or a bunch of method, you should consider giving them their
own autorelease pool, and release it sometimes during the process to clear the
memory.
Fred
Quoting Sandeep Chandna <email@hidden>:
> Hi,
>
>
> I am seeing some memory leaks in my application and tried various
>
> tools to figure out the cause but haven't been successful so far.
>
> Any pointers regarding the problem would be helpful. The leaks are
> seen only on the mac (no noticeable leak on windows) in the order of
> 10s of MBs (as shown by activity monitor).
>
>
>
> - Using the command line tool 'leaks' (with MallocStackLogging)
>
> showed only 0.5MB of memory leak which is far less than the actual amount of
> leak.
>
> This information does not seem to be correct as the activity monitor
>
> shows the amount of leak to be much larger than this.
>
> - Using MallocDebug showed almost same information as leaks.
>
> - ObjectAlloc showed slightly higher amount of memory leaked but
> it
>
> incorrectly reported objects that were deleted as leaks. The objects
>
> in question were CF objects wrapped around a ScopedDeleter. Moreover,
>
> ObjectAlloc didn't show a full stack crawl as the functions close to
> the top of the stack were missing in some cases.
>
> Leaks/ObjectAlloc etc shows maximum of 1MB memory leak in my app whereas
> Activity monitor shows memory increase by few 10s of MBs. What could be
> going
> wrong here? Is it possible that Activity monitor is showing memory increase
> even when there is no memory leak? could Activity monitor's memory increase
> be
> just because of fragmentation?
>
>
>
> Is there any better tool to find memory leaks on Mac? Is
>
> there any setting of the utilities mentioned above that we could tweak to
> get more relevant information?
>
> Any help is appreciated
> Thanks
> Sandeep
>
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden