discuss-gnustep
[Top][All Lists]
Advanced

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

Re: Use of NSZoneStat()


From: Ivan Vučica
Subject: Re: Use of NSZoneStat()
Date: Thu, 8 Mar 2018 16:25:59 +0000

What you're doing won't work, as far as I can tell.

Header:

/** Deprecated ...<br />
 *  Obtain statistics about the zone.  Implementation emphasis is on
 *  correctness, not speed.  Not defined by OpenStep or OS X.
 */
struct NSZoneStats
NSZoneStats (NSZone *zone);

Implementation:

static struct NSZoneStats
default_stats (NSZone *zone)
{
  struct NSZoneStats dummy = {0,0,0,0,0};

  /* We can't obtain statistics from the memory managed by malloc(). */
  [NSException raise: NSGenericException
      format: @"No statistics for default zone"];
  return dummy;
}

static NSZone default_zone =
{
  default_malloc, default_realloc, default_free, default_recycle,
  default_check, default_lookup, default_stats, 0, @"default", 0
};

NSZone*
NSDefaultMallocZone (void)
{
  return &default_zone;
}

struct NSZoneStats
NSZoneStats (NSZone *zone)
{
  if (!zone)
    zone = NSDefaultMallocZone();
  return (zone->stats)(zone);
}



On Thu, Mar 8, 2018 at 4:19 PM, Gregory Casamento <address@hidden> wrote:
Did you test this on Mac OS X?  What results are returned there?

On Thu, Mar 8, 2018 at 11:14 amon <address@hidden> 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

--
+---------------------------------------------------------------+
|   Dale Amon                  Immortal Data                    |
|   CEO             Midland International Air and Space Port    |
| address@hidden       "Data Systems for Deep Space and Time"     |
+---------------------------------------------------------------+

_______________________________________________
Discuss-gnustep mailing list
address@hidden
https://lists.gnu.org/mailman/listinfo/discuss-gnustep
--
Gregory Casamento
GNUstep Lead Developer / OLC, Principal Consultant
http://www.gnustep.org - http://heronsperch.blogspot.com
http://ind.ie/phoenix/

_______________________________________________
Discuss-gnustep mailing list
address@hidden
https://lists.gnu.org/mailman/listinfo/discuss-gnustep



reply via email to

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