Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Free more things that we allocate

  • Loading branch information...
commit ed12b7043fa98928f75c289a756fbcef546315f8 1 parent 1f801e3
@igfoo igfoo authored
View
10 rts/Capability.c
@@ -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
+}
View
3  rts/Capability.h
@@ -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
* -------------------------------------------------------------------------- */
View
19 rts/ProfHeap.c
@@ -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);
View
6 rts/Profiling.c
@@ -186,6 +186,12 @@ initProfiling1 (void)
}
void
+freeProfiling1 (void)
+{
+ arenaFree(prof_arena);
+}
+
+void
initProfiling2 (void)
{
CostCentreStack *ccs, *next;
View
1  rts/Profiling.h
@@ -13,6 +13,7 @@
#if defined(PROFILING) || defined(DEBUG)
void initProfiling1 ( void );
+void freeProfiling1 ( void );
void initProfiling2 ( void );
void endProfiling ( void );
View
2  rts/RtsSignals.h
@@ -41,6 +41,8 @@ extern void initUserSignals(void);
*/
extern void initDefaultHandlers(void);
+extern void freeSignalHandlers(void);
+
/*
* Function: blockUserSignals()
*
View
8 rts/RtsStartup.c
@@ -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();
View
5 rts/Schedule.c
@@ -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
View
7 rts/posix/Signals.c
@@ -545,4 +545,11 @@ initDefaultHandlers()
#endif
}
+void
+freeSignalHandlers(void) {
+ if (signal_handlers != NULL) {
+ stgFree(signal_handlers);
+ }
+}
+
#endif /* RTS_USER_SIGNALS */
View
5 rts/win32/ConsoleHandler.c
@@ -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)
Please sign in to comment.
Something went wrong with that request. Please try again.