Changeset 1918 for trunk/src/kmk/misc.c
- Timestamp:
- Oct 23, 2008, 11:27:11 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/kmk/misc.c
r1876 r1918 22 22 #ifdef CONFIG_WITH_VALUE_LENGTH 23 23 # include <assert.h> 24 #endif 25 #ifdef CONFIG_WITH_PRINT_STATS_SWITCH 26 # ifdef __APPLE__ 27 # include <malloc/malloc.h> 28 # endif 24 29 #endif 25 30 … … 1326 1331 1327 1332 #endif /* CONFIG_WITH_ALLOC_CACHES */ 1333 1334 #ifdef CONFIG_WITH_PRINT_STATS_SWITCH 1335 /* Print heap statistics if supported by the platform. */ 1336 void print_heap_stats (void) 1337 { 1338 /* Darwin / Mac OS X */ 1339 # ifdef __APPLE__ 1340 malloc_statistics_t s; 1341 1342 malloc_zone_statistics (NULL, &s); 1343 printf (_("\n# CRT Heap: %zu bytes in use, in %u block, avg %zu bytes/block\n"), 1344 s.size_in_use, s.blocks_in_use, s.size_in_use / s.blocks_in_use); 1345 printf (_("# %zu bytes max in use (high water mark)\n"), 1346 s.max_size_in_use); 1347 printf (_("# %zu bytes reserved, %zu bytes free (estimate)\n"), 1348 s.size_allocated, s.size_allocated - s.size_in_use); 1349 # endif /* __APPLE__ */ 1350 1351 /* Darwin Libc sources indicates that something like this may be 1352 found in GLIBC, however, it's not in any current one... */ 1353 # if 0 /* ??? */ 1354 struct mstats m; 1355 1356 m = mstats(); 1357 printf (_("\n# CRT Heap: %zu blocks / %zu bytes in use, %zu blocks / %zu bytes free\n"), 1358 m.chunks_used, m.bytes_used, m.chunks_free, m.bytes_free); 1359 printf (_("# %zu bytes reserved\n"), 1360 m.bytes_total); 1361 # endif /* ??? */ 1362 1363 /* XVID2/XPG mallinfo (displayed per GLIBC documentation). */ 1364 # if 0 && defined(__GLIBC__) /* XXX: finish on linux, check older glibc versions. */ 1365 struct mallinfo m; 1366 1367 m = mallinfo(); 1368 printf (_("\n# CRT Heap: %d bytes in use, %d bytes free\n"), 1369 m.uordblks, s.fordblks); 1370 1371 printf (_("# # free chunks=%d, # fastbin blocks=%d\n"), 1372 m.ordblks, m.smblks); 1373 printf (_("# # mapped regions=%d, space in mapped regions=%d\n"), 1374 m.hblks, m.hblkhd); 1375 printf (_("# non-mapped space allocated from system=%d\n"), 1376 m.arena); 1377 printf (_("# maximum total allocated space=%d\n"), 1378 m.usmblks); 1379 printf (_("# top-most releasable space=%d\n"), 1380 m.keepcost); 1381 # endif /* __GLIBC__ */ 1382 1383 /* XXX: windows */ 1384 } 1385 #endif /* CONFIG_WITH_PRINT_STATS_SWITCH */ 1386
Note:
See TracChangeset
for help on using the changeset viewer.