projects
/
ghc-hetmet.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
1f801e3
)
Free more things that we allocate
2006-12-16
author
Ian Lynagh
<igloo@earth.li>
Fri, 15 Dec 2006 21:44:30 +0000
(21:44 +0000)
committer
Ian Lynagh
<igloo@earth.li>
Fri, 15 Dec 2006 21:44:30 +0000
(21:44 +0000)
rts/Capability.c
patch
|
blob
|
history
rts/Capability.h
patch
|
blob
|
history
rts/ProfHeap.c
patch
|
blob
|
history
rts/Profiling.c
patch
|
blob
|
history
rts/Profiling.h
patch
|
blob
|
history
rts/RtsSignals.h
patch
|
blob
|
history
rts/RtsStartup.c
patch
|
blob
|
history
rts/Schedule.c
patch
|
blob
|
history
rts/posix/Signals.c
patch
|
blob
|
history
rts/win32/ConsoleHandler.c
patch
|
blob
|
history
diff --git
a/rts/Capability.c
b/rts/Capability.c
index
3d55b42
..
510656f
100644
(file)
--- a/
rts/Capability.c
+++ b/
rts/Capability.c
@@
-673,8
+673,7
@@
shutdownCapability (Capability *cap, Task *task)
continue;
}
debugTrace(DEBUG_sched, "capability %d is stopped.", cap->no);
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;
}
RELEASE_LOCK(&cap->lock);
break;
}
@@
-712,4
+711,11
@@
tryGrabCapability (Capability *cap, Task *task)
#endif /* THREADED_RTS */
#endif /* THREADED_RTS */
+void
+freeCapability (Capability *cap) {
+ stgFree(cap->mut_lists);
+#if defined(THREADED_RTS) || defined(PARALLEL_HASKELL)
+ freeSparkPool(&cap->r.rSparks);
+#endif
+}
diff --git
a/rts/Capability.h
b/rts/Capability.h
index
dd17863
..
dedd635
100644
(file)
--- a/
rts/Capability.h
+++ b/
rts/Capability.h
@@
-232,6
+232,9
@@
extern void grabCapability (Capability **pCap);
#endif /* !THREADED_RTS */
#endif /* !THREADED_RTS */
+// Free a capability on exit
+void freeCapability (Capability *cap);
+
/* -----------------------------------------------------------------------------
* INLINE functions... private below here
* -------------------------------------------------------------------------- */
/* -----------------------------------------------------------------------------
* INLINE functions... private below here
* -------------------------------------------------------------------------- */
diff --git
a/rts/ProfHeap.c
b/rts/ProfHeap.c
index
4aecd0b
..
e93151d
100644
(file)
--- a/
rts/ProfHeap.c
+++ b/
rts/ProfHeap.c
@@
-316,6
+316,13
@@
initEra(Census *census)
census->drag_total = 0;
}
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.
/* --------------------------------------------------------------------------
* 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) {
void initProfiling2( void )
{
if (RtsFlags.ProfFlags.doHeapProfile) {
@@
-493,6
+504,14
@@
endHeapProfiling(void)
}
#endif
}
#endif
+ {
+ nat t;
+ for (t = 0; t <= era; t++) {
+ freeEra( &censuses[t] );
+ }
+ }
+ stgFree(censuses);
+
seconds = mut_user_time();
printSample(rtsTrue, seconds);
printSample(rtsFalse, seconds);
seconds = mut_user_time();
printSample(rtsTrue, seconds);
printSample(rtsFalse, seconds);
diff --git
a/rts/Profiling.c
b/rts/Profiling.c
index
a865078
..
4e759b6
100644
(file)
--- a/
rts/Profiling.c
+++ b/
rts/Profiling.c
@@
-186,6
+186,12
@@
initProfiling1 (void)
}
void
}
void
+freeProfiling1 (void)
+{
+ arenaFree(prof_arena);
+}
+
+void
initProfiling2 (void)
{
CostCentreStack *ccs, *next;
initProfiling2 (void)
{
CostCentreStack *ccs, *next;
diff --git
a/rts/Profiling.h
b/rts/Profiling.h
index
d968349
..
edfc1b2
100644
(file)
--- a/
rts/Profiling.h
+++ b/
rts/Profiling.h
@@
-13,6
+13,7
@@
#if defined(PROFILING) || defined(DEBUG)
void initProfiling1 ( void );
#if defined(PROFILING) || defined(DEBUG)
void initProfiling1 ( void );
+void freeProfiling1 ( void );
void initProfiling2 ( void );
void endProfiling ( void );
void initProfiling2 ( void );
void endProfiling ( void );
diff --git
a/rts/RtsSignals.h
b/rts/RtsSignals.h
index
eafeeaa
..
6d9374a
100644
(file)
--- a/
rts/RtsSignals.h
+++ b/
rts/RtsSignals.h
@@
-41,6
+41,8
@@
extern void initUserSignals(void);
*/
extern void initDefaultHandlers(void);
*/
extern void initDefaultHandlers(void);
+extern void freeSignalHandlers(void);
+
/*
* Function: blockUserSignals()
*
/*
* Function: blockUserSignals()
*
diff --git
a/rts/RtsStartup.c
b/rts/RtsStartup.c
index
87df96a
..
7193876
100644
(file)
--- a/
rts/RtsStartup.c
+++ b/
rts/RtsStartup.c
@@
-378,6
+378,10
@@
hs_exit(void)
/* start timing the shutdown */
stat_startExit();
/* start timing the shutdown */
stat_startExit();
+#if defined(RTS_USER_SIGNALS)
+ freeSignalHandlers();
+#endif
+
#if defined(THREADED_RTS)
ioManagerDie();
#endif
#if defined(THREADED_RTS)
ioManagerDie();
#endif
@@
-447,6
+451,10
@@
hs_exit(void)
/* free the stable pointer table */
exitStablePtrTable();
/* free the stable pointer table */
exitStablePtrTable();
+#if defined(PROFILING) || defined(DEBUG)
+ freeProfiling1();
+#endif
+
#if defined(DEBUG)
/* free the thread label table */
freeThreadLabelTable();
#if defined(DEBUG)
/* free the thread label table */
freeThreadLabelTable();
diff --git
a/rts/Schedule.c
b/rts/Schedule.c
index
8ebedd4
..
a11a15e
100644
(file)
--- a/
rts/Schedule.c
+++ b/
rts/Schedule.c
@@
-2581,6
+2581,8
@@
exitScheduler( void )
boundTaskExiting(task);
stopTaskManager();
}
boundTaskExiting(task);
stopTaskManager();
}
+#else
+ freeCapability(&MainCapability);
#endif
}
#endif
}
@@
-2588,6
+2590,9
@@
void
freeScheduler( void )
{
freeTaskManager();
freeScheduler( void )
{
freeTaskManager();
+ if (n_capabilities != 1) {
+ stgFree(capabilities);
+ }
#if defined(THREADED_RTS)
closeMutex(&sched_mutex);
#endif
#if defined(THREADED_RTS)
closeMutex(&sched_mutex);
#endif
diff --git
a/rts/posix/Signals.c
b/rts/posix/Signals.c
index
a5044cd
..
2380eac
100644
(file)
--- a/
rts/posix/Signals.c
+++ b/
rts/posix/Signals.c
@@
-545,4
+545,11
@@
initDefaultHandlers()
#endif
}
#endif
}
+void
+freeSignalHandlers(void) {
+ if (signal_handlers != NULL) {
+ stgFree(signal_handlers);
+ }
+}
+
#endif /* RTS_USER_SIGNALS */
#endif /* RTS_USER_SIGNALS */
diff --git
a/rts/win32/ConsoleHandler.c
b/rts/win32/ConsoleHandler.c
index
5b5cfc3
..
a2de74b
100644
(file)
--- a/
rts/win32/ConsoleHandler.c
+++ b/
rts/win32/ConsoleHandler.c
@@
-52,6
+52,11
@@
initUserSignals(void)
return;
}
return;
}
+void
+freeSignalHandlers(void) {
+ /* Do nothing */
+}
+
/* Seems to be a bit of an orphan...where used? */
void
finiUserSignals(void)
/* Seems to be a bit of an orphan...where used? */
void
finiUserSignals(void)