Note that there are some explanatory texts on larger screens.

plurals
  1. POMemory Leak, Unsure if object is managed
    text
    copied!<p>I'm having trouble with a memory leak in C#. I'm seeing the memory usage in process manager increasing 10-20mb (and more) when no new objects should be getting created.</p> <p>q1) I am under the impression that managed objects will automatically be deleted by the GC. But when I profile the memory usage using dotTrace, there seems to be +10k instances (in the show new / dead differences) of a basic object I wrote. I found the place that it would be leaking if this were c++, </p> <pre><code>public void TriggerEvent(string tEvent) { oVariable tVar = GetVar(tEvent); if (tVar != null) sVariableParser.TriggerEvent(tVar); else { tVar = new oVariable("@CXZ_TEMP_VAR", tEvent, 0, this); tVar._BlockDependancies = true; sVariableParser.TriggerEvent(tVar); } } </code></pre> <p>Where oVariable is defined as</p> <pre><code>class oVariable : IComparable </code></pre> <p>It seems that the GC is not deleting the new'd oVariables, I am wondering do I need to implement oVariable as IDisposable and make a specific system call to make sure the GC collects it? There are also a few other custom objects within oVariable, but I was under the impression that simple objects which don't use anything external (no COM objects etc) should automatically be managed, or am I mistaken and I've been created unmanaged data structures? </p> <p>q2) Even with dotTrace Memory showing a lot of new oVariables where there should be zero (maybe the GC is lazy), I still have a feeling the memory leak could be coming from the windows forms, specifically DataGridViews. I was wondering if someone could tell me if I need to do any specific memory deallocation function calls after invoking a DGV update/redraw using </p> <pre><code>tGridView.Invoke(new UpdateGridViewCallBack(RedrawGlobalsViewGridView), tGridView); </code></pre> <p>I had assumed the new'd call back would clean up after itself. </p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload