Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Alex D
GHC
Commits
9f2ceb4d
Commit
9f2ceb4d
authored
Aug 08, 2006
by
Simon Marlow
Browse files
Remember to free() memory on exit
Patch mostly from Lennart Augustsson in #803, with additions to Task.c by me.
parent
3098d214
Changes
7
Hide whitespace changes
Inline
Side-by-side
includes/Stable.h
View file @
9f2ceb4d
...
...
@@ -55,6 +55,7 @@ extern StgPtr deRefStablePtr(StgStablePtr sp);
#endif
extern
void
initStablePtrTable
(
void
);
extern
void
exitStablePtrTable
(
void
);
extern
void
enlargeStablePtrTable
(
void
);
extern
StgWord
lookupStableName
(
StgPtr
p
);
...
...
@@ -63,4 +64,6 @@ extern void threadStablePtrTable ( evac_fn evac );
extern
void
gcStablePtrTable
(
void
);
extern
void
updateStablePtrTable
(
rtsBool
full
);
extern
void
exitHashTable
(
void
);
#endif
rts/Hash.c
View file @
9f2ceb4d
...
...
@@ -212,15 +212,25 @@ lookupHashTable(HashTable *table, StgWord key)
static
HashList
*
freeList
=
NULL
;
static
struct
chunkList
{
void
*
chunk
;
struct
chunkList
*
next
;
}
*
chunks
;
static
HashList
*
allocHashList
(
void
)
{
HashList
*
hl
,
*
p
;
struct
chunkList
*
cl
;
if
((
hl
=
freeList
)
!=
NULL
)
{
freeList
=
hl
->
next
;
}
else
{
hl
=
stgMallocBytes
(
HCHUNK
*
sizeof
(
HashList
),
"allocHashList"
);
cl
=
stgMallocBytes
(
sizeof
(
*
cl
),
"allocHashList: chunkList"
);
cl
->
chunk
=
hl
;
cl
->
next
=
chunks
;
chunks
=
cl
;
freeList
=
hl
+
1
;
for
(
p
=
freeList
;
p
<
hl
+
HCHUNK
-
1
;
p
++
)
...
...
@@ -374,3 +384,15 @@ allocStrHashTable(void)
return
allocHashTable_
((
HashFunction
*
)
hashStr
,
(
CompareFunction
*
)
compareStr
);
}
void
exitHashTable
(
void
)
{
struct
chunkList
*
cl
;
while
((
cl
=
chunks
)
!=
NULL
)
{
chunks
=
cl
->
next
;
stgFree
(
cl
->
chunk
);
stgFree
(
cl
);
}
}
rts/RtsStartup.c
View file @
9f2ceb4d
...
...
@@ -390,6 +390,12 @@ hs_exit(void)
// also outputs the stats (+RTS -s) info.
exitStorage
();
/* initialise the stable pointer table */
exitStablePtrTable
();
/* free hash table storage */
exitHashTable
();
#ifdef RTS_GTK_FRONTPANEL
if
(
RtsFlags
.
GcFlags
.
frontpanel
)
{
stopFrontPanel
();
...
...
rts/Stable.c
View file @
9f2ceb4d
...
...
@@ -159,6 +159,18 @@ initStablePtrTable(void)
#endif
}
void
exitStablePtrTable
(
void
)
{
if
(
addrToStableHash
)
freeHashTable
(
addrToStableHash
,
NULL
);
addrToStableHash
=
NULL
;
if
(
stable_ptr_table
)
stgFree
(
stable_ptr_table
);
stable_ptr_table
=
NULL
;
SPT_size
=
0
;
}
/*
* get at the real stuff...remove indirections.
*
...
...
rts/Stats.c
View file @
9f2ceb4d
...
...
@@ -537,6 +537,9 @@ stat_exit(int alloc)
statsFlush
();
statsClose
();
}
if
(
GC_coll_times
)
stgFree
(
GC_coll_times
);
GC_coll_times
=
NULL
;
}
/* -----------------------------------------------------------------------------
...
...
rts/Storage.c
View file @
9f2ceb4d
...
...
@@ -273,6 +273,11 @@ exitStorage (void)
void
freeStorage
(
void
)
{
nat
g
;
for
(
g
=
0
;
g
<
RtsFlags
.
GcFlags
.
generations
;
g
++
)
stgFree
(
generations
[
g
].
steps
);
stgFree
(
generations
);
freeAllMBlocks
();
}
...
...
rts/Task.c
View file @
9f2ceb4d
...
...
@@ -74,9 +74,19 @@ initTaskManager (void)
void
stopTaskManager
(
void
)
{
Task
*
task
,
*
next
;
debugTrace
(
DEBUG_sched
,
"stopping task manager, %d tasks still running"
,
tasksRunning
);
ACQUIRE_LOCK
(
&
sched_mutex
);
for
(
task
=
task_free_list
;
task
!=
NULL
;
next
)
{
next
=
task
->
next
;
stgFree
(
task
);
}
task_free_list
=
NULL
;
RELEASE_LOCK
(
&
sched_mutex
);
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment