discuss-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Use of NSZoneStat()


From: Richard Frith-Macdonald
Subject: Re: Use of NSZoneStat()
Date: Thu, 8 Mar 2018 16:39:50 +0000


> On 8 Mar 2018, at 16:15, amon <amon@vnl.com> wrote:
> 
> I am trying to get a handle on storage leaks and NSZoneStat()
> would be ideal... except it doesn't work.
> 
>  NSZone *dftzone = NSDefaultMallocZone();
>  NSZone *curzone = NSZoneFromPointer ( (void *) arglist);
>  printf ("dft = %lx cur  = %lx\n",
>         (long unsigned int) dftzone,
>         (long unsigned int) curzone);
> 
>  struct NSZoneStats zs0 = NSZoneStats (dftzone);
>  printf ("Bytes Used %d Free %d\n",
>         (int) zs0.bytes_used,
>         (int) zs0.bytes_free);
> 
> dft = 7ffcfdf26200 cur  = 7ffcfdf26200
> bin/gpstest: Uncaught exception NSGenericException, reason: No statistics for 
> default zone

NSZoneStat is only supposed to work for special zones you have created, not for 
the default zone.  It's for cirecumstances where you are carefully isolating 
your work in one or more non-standard zones.

If you are looking for general memory management, the default zone is 
implemented using malloc/free and you can substitute a different malloc library 
(eg tcmalloc) which will provide its own diagnostics.  This is not GNUstep 
specific stuff an you are better off asking in general (or C) programming 
forums.

If you are interested in object allocation/deallocation (rather than total heap 
memory), gnustep-base has a rich set of extensions to help with that (see 
NSDebug.h) as well as some extra stuff to help deal with autorelease pools.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]