brenkmanco / hackpdm

Open Source PDM System
GNU General Public License v3.0
19 stars 4 forks source link

Temporary Memory Leak #23

Closed matt454357 closed 9 years ago

matt454357 commented 9 years ago

After refreshing the view, it starts to gather huge amounts of memory for every operation. Then it cleans up and releases the memory after the operation completes.

matt454357 commented 9 years ago

It looks like the problem is here: https://github.com/brenkmanco/hackpdm/blob/master/HackPDM_CSharp/MainForm.cs#L517

MainForm.cs -> ResetView():

            if (strTreePath == "") {
                treeView1.SelectedNode = tnRoot;
                PopulateList(tnRoot);
            } else {
                tnSelect = FindNode(tnRoot, strTreePath);
                if (tnSelect != null) {
>-------------------treeView1.SelectedNode = tnSelect;
                    PopulateList(tnSelect);
                } else {
                    treeView1.SelectedNode = tnRoot;
                    PopulateList(tnRoot);
                }
            }

But, I don't understand why this would happen.

briggsj3 commented 9 years ago

I added logic to check if treeVeiw1.SelectedNode was already set to the clicked node, but then I realized that the entire tree is wiped and rebuilt each time, so there is no chance of it already being set to anything except null. Now doing more Google searching to see what else comes up...

On Mon, Jun 1, 2015 at 10:50 AM, Matt Taylor notifications@github.com wrote:

It looks like the problem is here: https://github.com/brenkmanco/hackpdm/blob/master/HackPDM_CSharp/MainForm.cs#L517

MainForm.cs -> ResetView():

        if (strTreePath == "") {
            treeView1.SelectedNode = tnRoot;
            PopulateList(tnRoot);
        } else {
            tnSelect = FindNode(tnRoot, strTreePath);
            if (tnSelect != null) {

-------------------treeView1.SelectedNode = tnSelect; PopulateList(tnSelect); } else { treeView1.SelectedNode = tnRoot; PopulateList(tnRoot); } }

But, I don't understand why this would happen.

— Reply to this email directly or view it on GitHub https://github.com/brenkmanco/hackpdm/issues/23#issuecomment-107633999.

matt454357 commented 9 years ago

This issue appears to be what we are experiencing (although it is for an older version): http://www.tech-archive.net/Archive/DotNet/microsoft.public.dotnet.framework.windowsforms.controls/2006-08/msg00266.html

briggsj3 commented 9 years ago

I'd seen something very similar to that reported for a not-so-old version, but I couldn't replicate it on my end, and I haven't found anyone mentioning how to get around it.

Do you think the amount of memory leakage that you're seeing could really be caused by something like this, though? That's a lot of memory being wasted just because the treenodes aren't being garbage collected...

On Thu, Jun 4, 2015 at 2:34 PM, Matt Taylor notifications@github.com wrote:

This issue appears to be what we are experiencing (although it is for an older version):

http://www.tech-archive.net/Archive/DotNet/microsoft.public.dotnet.framework.windowsforms.controls/2006-08/msg00266.html

— Reply to this email directly or view it on GitHub https://github.com/brenkmanco/hackpdm/issues/23#issuecomment-109040832.

matt454357 commented 9 years ago

Yes. This could easily leak that much memory, if the guy is right. We have 2000 directories. If you refresh the view 3 times, you would be holding 8 billion directories treenodes in memory.

briggsj3 commented 9 years ago

Wow, you weren't kidding that you had a large set of files! That makes sense. I'll keep looking in that direction, then.

On Thu, Jun 4, 2015 at 2:49 PM, Matt Taylor notifications@github.com wrote:

Yes. This could easily leak that much memory, if the guy is right. We have 2000 directories. If you refresh the view 3 times, you would be holding 8 billion directories treenodes in memory.

— Reply to this email directly or view it on GitHub https://github.com/brenkmanco/hackpdm/issues/23#issuecomment-109045472.

matt454357 commented 9 years ago

I think we're either on the wrong track, or I discovered another issue. There's a problem with the regular expression I'm using to match weird file extension formats. The pattern for the regex grows every time the view is refreshed. I discovered it here: https://github.com/brenkmanco/hackpdm/blob/master/HackPDM_CSharp/FileTypeManager.cs#L470

matt454357 commented 9 years ago

This appears to fix this issue. At least, I no longer see the symptoms.