[Issue 4369] New: Multiple bugs in GC minimize()
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Tue Jun 22 19:58:57 PDT 2010
http://d.puremagic.com/issues/show_bug.cgi?id=4369
Summary: Multiple bugs in GC minimize()
Product: D
Version: D2
Platform: All
OS/Version: All
Status: NEW
Severity: normal
Priority: P2
Component: druntime
AssignedTo: sean at invisibleduck.org
ReportedBy: llucax at gmail.com
--- Comment #0 from Leandro Lucarella <llucax at gmail.com> 2010-06-22 19:58:53 PDT ---
This is basically the same bug I reported to Tango:
http://www.dsource.org/projects/tango/ticket/1941
I found a couple of bugs in the minimize() function of the GC.
Here is some kind of patch that fixes the bugs (and add a little enhancement),
with inline comments (this is found in gc/gcx.d):
---
/**
* Minimizes physical memory usage by returning free pools to the OS.
*/
void minimize()
{
size_t n;
size_t pn;
Pool* pool;
size_t ncommitted;
for (n = 0; n < npools; n++)
{
pool = pooltable[n];
ncommitted = pool.ncommitted;
for (pn = 0; pn < ncommitted; pn++)
{
if (cast(Bins)pool.pagetable[pn] != B_FREE)
break;
}
if (pn < ncommitted)
{
- n++; // n++ is done by the for loop, this skips a pool
continue;
}
pool.Dtor();
cstdlib.free(pool);
cstring.memmove(pooltable + n,
pooltable + n + 1,
(--npools - n) * (Pool*).sizeof);
+ n--; // without this, we are skipping the first moved pool
- minAddr = pooltable[0].baseAddr;
- maxAddr = pooltable[npools - 1].topAddr;
}
+ minAddr = pooltable[0].baseAddr; // there is no point on doing
+ maxAddr = pooltable[npools - 1].topAddr; // this for each moved pool
}
---
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list