Bug 14573 – [REG2.067] Extreme memory usage when `synchronized( object )` is used

Status
RESOLVED
Resolution
FIXED
Severity
regression
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
Linux
Creation time
2015-05-11T10:55:00Z
Last change time
2017-07-19T17:41:41Z
Keywords
pull
Assigned to
code
Creator
14crgg+ekargo2d7qijk

Attachments

IDFilenameSummaryContent-TypeSize
1521testcode.dExample codeapplication/x-dsrc404

Comments

Comment #0 by 14crgg+ekargo2d7qijk — 2015-05-11T10:55:22Z
Created attachment 1521 Example code On DMD 2.067.1, when `synchronized` keyword is used with a parameter that is `this` or just another shared object, memory consumption increases continuously. I am informed that on DMD 2.066.0, this is not the case, and it doesn't increase memory consumption. As seen in the example file, if object is destroyed by using `destroy` function, even the `synchronized` is used with an object, memory usage is still stable.
Comment #1 by kozzi11 — 2015-05-13T14:24:51Z
Comment #2 by code — 2015-05-13T15:26:45Z
Sounds like the object mutexes aren't freed. They're usually explicity destroyed when finalizing a class. Might need to collect them by the GC separately.
Comment #3 by safety0ff.bugz — 2015-05-13T17:07:21Z
Probably best just to revert the commit in question for now and leave a comment in _d_newclass explaining why classes need the FINALIZE flag regardless. The other commit in PR #873 can stay.
Comment #4 by code — 2015-05-14T17:16:57Z
(In reply to safety0ff.bugz from comment #3) > Probably best just to revert the commit in question for now and leave a > comment in _d_newclass explaining why classes need the FINALIZE flag > regardless. I'm so tired of this reverting business, let's just fix the bug. We have 2 options - introduce a finalizeMonitor flag that tells the GC to only free the monitor - try to add a quickpath in rt_finalize2 to skip destruction, but keep the FINALIZE flag, even for classes without a dtor
Comment #5 by safety0ff.bugz — 2015-05-14T17:50:10Z
(In reply to Martin Nowak from comment #4) > > I'm so tired of this reverting business, let's just fix the bug. > We have 2 options > > - introduce a finalizeMonitor flag that tells the GC to only free the monitor > - try to add a quickpath in rt_finalize2 to skip destruction, but keep the > FINALIZE flag, even for classes without a dtor I think introducing another flag will be overhead for little gain (flags aren't cheap currently.) The first idea that came to mind was to add FINALIZE in _d_monitor_create, not sure if it'll work. I don't have the time for a fix that will require me to check the monitor source code, which is why I talked about reverting + comment.
Comment #6 by code — 2015-05-14T18:24:57Z
(In reply to safety0ff.bugz from comment #5) > The first idea that came to mind was to add FINALIZE in _d_monitor_create, > not sure if it'll work. Interesting idea.
Comment #7 by code — 2015-05-14T18:33:22Z
(In reply to Martin Nowak from comment #6) > Interesting idea. Even better would be to pick up the old explicit @monitor idea and finally implement it. https://github.com/D-Programming-Language/dmd/pull/3547
Comment #8 by code — 2015-05-14T18:47:28Z
Comment #9 by github-bugzilla — 2015-05-20T12:30:41Z
Commit pushed to master at https://github.com/D-Programming-Language/druntime https://github.com/D-Programming-Language/druntime/commit/d50aba0083b03659f60c3f157a674d9846d8228f fix Issue 14573 - classes without destructor leak monitor/mutex - set finalize bit when constructing the monitor
Comment #10 by github-bugzilla — 2015-06-17T21:02:51Z
Comment #11 by github-bugzilla — 2017-07-19T17:41:41Z
Commit pushed to dmd-cxx at https://github.com/dlang/druntime https://github.com/dlang/druntime/commit/d50aba0083b03659f60c3f157a674d9846d8228f fix Issue 14573 - classes without destructor leak monitor/mutex