/* -----------------------------------------------------------------------------
- * $Id: Storage.c,v 1.25 2000/04/26 11:54:28 simonmar Exp $
+ * $Id: Storage.c,v 1.30 2000/12/11 12:37:00 simonmar Exp $
*
* (c) The GHC Team, 1998-1999
*
#include "Hooks.h"
#include "BlockAlloc.h"
#include "MBlock.h"
-#include "gmp.h"
#include "Weak.h"
#include "Sanity.h"
generation *oldest_gen; /* oldest generation, for convenience */
step *g0s0; /* generation 0, step 0, for convenience */
+lnat total_allocated = 0; /* total memory allocated during run */
+
/*
* Storage manager mutex: protects all the above state from
* simultaneous access by two STG threads.
void
exitStorage (void)
{
- stat_exit(calcAllocated());
+ stat_exit(calcAllocated());
}
+/* -----------------------------------------------------------------------------
+ Setting the heap size. This function is callable from Haskell (GHC
+ uses it to implement the -H<size> option).
+ -------------------------------------------------------------------------- */
+
+void
+setHeapSize( HsInt size )
+{
+ RtsFlags.GcFlags.heapSizeSuggestion = size / BLOCK_SIZE;
+ if (RtsFlags.GcFlags.heapSizeSuggestion >
+ RtsFlags.GcFlags.maxHeapSize) {
+ RtsFlags.GcFlags.maxHeapSize = RtsFlags.GcFlags.heapSizeSuggestion;
+ }
+}
/* -----------------------------------------------------------------------------
CAF management.
/* allocate and fill it in. */
arr = (StgArrWords *)allocate(total_size_in_words);
- SET_ARR_HDR(arr, &ARR_WORDS_info, CCCS, data_size_in_words);
+ SET_ARR_HDR(arr, &stg_ARR_WORDS_info, CCCS, data_size_in_words);
/* and return a ptr to the goods inside the array */
return(BYTE_ARR_CTS(arr));
}
#endif
+ total_allocated += allocated;
return allocated;
}