Commit ed12b704 authored by Ian Lynagh's avatar Ian Lynagh

Free more things that we allocate

parent 1f801e3a
......@@ -673,8 +673,7 @@ shutdownCapability (Capability *cap, Task *task)
continue;
}
debugTrace(DEBUG_sched, "capability %d is stopped.", cap->no);
stgFree(cap->mut_lists);
freeSparkPool(&cap->r.rSparks);
freeCapability(cap);
RELEASE_LOCK(&cap->lock);
break;
}
......@@ -712,4 +711,11 @@ tryGrabCapability (Capability *cap, Task *task)
#endif /* THREADED_RTS */
void
freeCapability (Capability *cap) {
stgFree(cap->mut_lists);
#if defined(THREADED_RTS) || defined(PARALLEL_HASKELL)
freeSparkPool(&cap->r.rSparks);
#endif
}
......@@ -232,6 +232,9 @@ extern void grabCapability (Capability **pCap);
#endif /* !THREADED_RTS */
// Free a capability on exit
void freeCapability (Capability *cap);
/* -----------------------------------------------------------------------------
* INLINE functions... private below here
* -------------------------------------------------------------------------- */
......
......@@ -316,6 +316,13 @@ initEra(Census *census)
census->drag_total = 0;
}
STATIC_INLINE void
freeEra(Census *census)
{
arenaFree(census->arena);
freeHashTable(census->hash, NULL);
}
/* --------------------------------------------------------------------------
* Increases era by 1 and initialize census[era].
* Reallocates gi[] and increases its size if needed.
......@@ -355,6 +362,10 @@ void initProfiling1( void )
{
}
void freeProfiling1( void )
{
}
void initProfiling2( void )
{
if (RtsFlags.ProfFlags.doHeapProfile) {
......@@ -493,6 +504,14 @@ endHeapProfiling(void)
}
#endif
{
nat t;
for (t = 0; t <= era; t++) {
freeEra( &censuses[t] );
}
}
stgFree(censuses);
seconds = mut_user_time();
printSample(rtsTrue, seconds);
printSample(rtsFalse, seconds);
......
......@@ -185,6 +185,12 @@ initProfiling1 (void)
*/
}
void
freeProfiling1 (void)
{
arenaFree(prof_arena);
}
void
initProfiling2 (void)
{
......
......@@ -13,6 +13,7 @@
#if defined(PROFILING) || defined(DEBUG)
void initProfiling1 ( void );
void freeProfiling1 ( void );
void initProfiling2 ( void );
void endProfiling ( void );
......
......@@ -41,6 +41,8 @@ extern void initUserSignals(void);
*/
extern void initDefaultHandlers(void);
extern void freeSignalHandlers(void);
/*
* Function: blockUserSignals()
*
......
......@@ -378,6 +378,10 @@ hs_exit(void)
/* start timing the shutdown */
stat_startExit();
#if defined(RTS_USER_SIGNALS)
freeSignalHandlers();
#endif
#if defined(THREADED_RTS)
ioManagerDie();
#endif
......@@ -447,6 +451,10 @@ hs_exit(void)
/* free the stable pointer table */
exitStablePtrTable();
#if defined(PROFILING) || defined(DEBUG)
freeProfiling1();
#endif
#if defined(DEBUG)
/* free the thread label table */
freeThreadLabelTable();
......
......@@ -2581,6 +2581,8 @@ exitScheduler( void )
boundTaskExiting(task);
stopTaskManager();
}
#else
freeCapability(&MainCapability);
#endif
}
......@@ -2588,6 +2590,9 @@ void
freeScheduler( void )
{
freeTaskManager();
if (n_capabilities != 1) {
stgFree(capabilities);
}
#if defined(THREADED_RTS)
closeMutex(&sched_mutex);
#endif
......
......@@ -545,4 +545,11 @@ initDefaultHandlers()
#endif
}
void
freeSignalHandlers(void) {
if (signal_handlers != NULL) {
stgFree(signal_handlers);
}
}
#endif /* RTS_USER_SIGNALS */
......@@ -52,6 +52,11 @@ initUserSignals(void)
return;
}
void
freeSignalHandlers(void) {
/* Do nothing */
}
/* Seems to be a bit of an orphan...where used? */
void
finiUserSignals(void)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment