Freeing memory when closing MDI window

Posted on 2004-11-14
Last Modified: 2010-04-24
I have this application in, it's got a mainwindow that allows the user to do a search and when the SEARCH button is pressed the result is displayed in an MDI-child window. While watching Windows Task Manager and doing another 20 searches my application takes up over 100'000Kb of memory. Ok, it does have 20 MDI windows open with a datagrid on, so that might be fair(?).

BUT, when closing all these MDI-childwindows, according to Task Manager it doesnt release any memory at all. So if I then start to go berserk on the SEARCH button again it takes up even more memory!

It is still a very simple app, what should I do?

Regards Anders
Question by:snoffy
    LVL 14

    Accepted Solution

    Sounds like you need to force the garbage collector to run.  In the portion of code that releases your MDI resources add this line:


    That will force the garbage collector to actually release the resources.


    Author Comment

    That did A LOT, but not all. Doing 30 searches and closing them leaks about 7 Mb of memory.

    Any thing else I could do?

    LVL 25

    Expert Comment


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    What Security Threats Are You Missing?

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    I'm currently working for a company where I have to upgrade over 50 VB6 programs to VB.NET 2008.  So far I'm about half way through, and I've learned quite a few tricks that drastically improve the performance of VB.NET apps. Because there are a…
    Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
    In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
    Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

    737 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    22 Experts available now in Live!

    Get 1:1 Help Now