Massive Program Crashes. Need Help Reducing Memory Footprint

So how to do show a list of open windows that were not closed properly or accidentally opened due to implicit instance. I tried view with WindowCount and displayed the number of windows open when I hit my main screen again. It always shows one window is open, just the main window. Any way of getting number for windows that are hidden currently?

Check Runtime.ObjectCount. It should go down even if memory doesn’t go down immediately. If ObjectCount isn’t going down, then you have a real problem. Using RealStudio here, MemoryUsed doesn’t track directly with window open and close, but it does eventually go down. Implicit instance doesn’t seem to make a difference. ObjectCount tracks nicely with window open/close.

To see if your windows are being released, add a constructor and destructor to your windows that increments/decrements a global variable e.g. windowcounter. If the number keeps climbing you know you have issues you need to address. In those methods put a system.DebugLog(CurrentMethodName) so you can see what is being created/released. You could even get extra fancy and create an array of strings (strings wont keep your windows alive for example if you had an array of windows they would) so you can list all windows that are still active/have a reference keeping them alive so you can go code mining to find those code nuggets :slight_smile:

Or you could use Runtime to list off your active objects and check those for windows :slight_smile:

Basically yes.
Instead of

frmNewCustomer.show

do

dim fnc as new frmNewCustomer fnc.show //or showmodal

When the save button is pressed (or the window is closed), ensure the data it handles is properly saved.
Dimming in a method here ensures that when the method ends (after the form is closed), the window is destroyed and the memory is freed up.

Did you check for incidental circular references? XojoInstruments should help to find some (if there are).