/* -----------------------------------------------------------------------------
- * $Id: Storage.c,v 1.66 2002/05/14 08:17:38 matthewc Exp $
+ * $Id: Storage.c,v 1.69 2002/10/15 11:02:32 simonmar Exp $
*
* (c) The GHC Team, 1998-1999
*
#include "RetainerProfile.h" // for counting memory blocks (memInventory)
+#include <stdlib.h>
+#include <string.h>
+
#ifdef darwin_TARGET_OS
#include <mach-o/getsect.h>
unsigned long macho_etext = 0;
StgClosure *caf_list = NULL;
bdescr *small_alloc_list; /* allocate()d small objects */
-bdescr *large_alloc_list; /* allocate()d large objects */
bdescr *pinned_object_block; /* allocate pinned objects into this block */
nat alloc_blocks; /* number of allocate()d blocks since GC */
nat alloc_blocks_lim; /* approximate limit on alloc_blocks */
/* initialise the allocate() interface */
small_alloc_list = NULL;
- large_alloc_list = NULL;
alloc_blocks = 0;
alloc_blocks_lim = RtsFlags.GcFlags.minAllocAreaSize;
lnat
allocated_bytes( void )
{
- return (alloc_blocks * BLOCK_SIZE_W - (alloc_HpLim - alloc_Hp));
+ lnat allocated;
+
+ allocated = alloc_blocks * BLOCK_SIZE_W - (alloc_HpLim - alloc_Hp);
+ if (pinned_object_block != NULL) {
+ allocated -= (pinned_object_block->start + BLOCK_SIZE_W) -
+ pinned_object_block->free;
+ }
+
+ return allocated;
}
/* ---------------------------------------------------------------------------
for (bd = small_alloc_list; bd; bd = bd->link) {
total_blocks += bd->blocks;
}
- for (bd = large_alloc_list; bd; bd = bd->link) {
- total_blocks += bd->blocks;
- }
#ifdef PROFILING
if (RtsFlags.ProfFlags.doHeapProfile == HEAP_BY_RETAINER) {