[219] Solution-linked GDI resource leak?

Since at least 218 (possibly 217), when closing the solution file (including
on exit), there is a period of very high CPU utilization and screen flicker.

This seems consistent with a subtle sort of bug that I've seen before:

class DisposableObject : IDisposable{
UnmanagedResource unmanaged;
DisposableObject(DisposableObject template){
// clone equivalent functionality here
this.unmanaged = template.GetUnmanagedResourceSomehow().Clone();
}

private DisposableObject(){
// internal constructor code here
}
static DisposableObject CreateDisposableObject(string
someConstructionInformation){
DisposableObject iHoldUnmanagedResources = new DisposableObject();
// creation code here to instantiate with the argument
}
}

then consuming code that does:

DisposableObject instance = new
DisposableObject(DisposableObject.CreateDisposableObject(myArguments));

which will leak an UnmanagedResource every time it gets called.

Seems like this sort of thing might be happening with GDI resources in R#R,
as I just repro'd the flicker-and-high-utilization by closing all open
files, then closing the solution.

Jonathan Choy


3 comments
Comment actions Permalink

Hello Jonathan,

we're investigating the problem with flicker as well as possible GDI leaks.
However, I'm not sure these
two problems are related, as invalidating all windows in the system may also
cause flicker.


Regards,
Dmitry Shaporenkov
JetBrains, Inc
http://www.jetbrains.com
"Develop with pleasure!"

Since at least 218 (possibly 217), when closing the solution file
(including on exit), there is a period of very high CPU utilization
and screen flicker.

This seems consistent with a subtle sort of bug that I've seen before:

class DisposableObject : IDisposable{
UnmanagedResource unmanaged;
DisposableObject(DisposableObject template){
// clone equivalent functionality here
this.unmanaged = template.GetUnmanagedResourceSomehow().Clone();
}
private DisposableObject(){
// internal constructor code here
}
static DisposableObject CreateDisposableObject(string
someConstructionInformation){
DisposableObject iHoldUnmanagedResources = new DisposableObject();
// creation code here to instantiate with the argument
}
}
then consuming code that does:

DisposableObject instance = new
DisposableObject(DisposableObject.CreateDisposableObject(myArguments))
;

which will leak an UnmanagedResource every time it gets called.

Seems like this sort of thing might be happening with GDI resources in
R#R, as I just repro'd the flicker-and-high-utilization by closing all
open files, then closing the solution.

Jonathan Choy



0
Comment actions Permalink

Hello Jonathan,

thanks for your template, I spent some time thinking of it, but it seems
unlikely that
we have similar code. Also, system GDI-related IDisposables (like Pen, Brush,
Font etc) have finalizer,
which should eventually release the underlying unmanaged object. Although
I agree that during application shutdown not disposing those objects may
cause problems.

Another incarnation of what seems to be a GDI resource leak in ReSharper
is the error stripe (the error indicator on the right of the editor) suddenly
stopping to paint properly or disappearing images in code
completion lists, or toolbars in the Find Results window. Some time ago we
did a manual code revision making
sure that all System.Drawing IDisposables are actually disposed, not finalized
(like in your code sample with not disposing inline-created object passed
as an argument). This seems to help a bit, but the paint problems still happen
from time to time.

Regards,
Dmitry Shaporenkov
JetBrains, Inc
http://www.jetbrains.com
"Develop with pleasure!"

Since at least 218 (possibly 217), when closing the solution file
(including on exit), there is a period of very high CPU utilization
and screen flicker.

This seems consistent with a subtle sort of bug that I've seen before:

class DisposableObject : IDisposable{
UnmanagedResource unmanaged;
DisposableObject(DisposableObject template){
// clone equivalent functionality here
this.unmanaged = template.GetUnmanagedResourceSomehow().Clone();
}
private DisposableObject(){
// internal constructor code here
}
static DisposableObject CreateDisposableObject(string
someConstructionInformation){
DisposableObject iHoldUnmanagedResources = new DisposableObject();
// creation code here to instantiate with the argument
}
}
then consuming code that does:

DisposableObject instance = new
DisposableObject(DisposableObject.CreateDisposableObject(myArguments))
;

which will leak an UnmanagedResource every time it gets called.

Seems like this sort of thing might be happening with GDI resources in
R#R, as I just repro'd the flicker-and-high-utilization by closing all
open files, then closing the solution.

Jonathan Choy



0
Comment actions Permalink

Another avenue of investigation might be the VS Command cleanup on shutdown
code... because of the number of command objects you're pulling out of
Studio's stack when transitioning from open solution -> no solution (covers
all scenarios of shutdown, close solution, unload R#R addin)... I noticed
the massive number of named Command objects flickering past in the status
bar whilst unloading R#R today so I could debug more of my boss' application
framework code without continuous exception throwing badness.

tossing ideas over the wall again,

Jon


0

Please sign in to leave a comment.