So I made this awesome graphing program. Here’s how it works:
[LIST=1]
[]The user makes selections for a time period, a person, and a metric.
[]Once the selections are made, the user clicks an OK button and the application loads in a 12MB XML database.
[]Next, there is a complex loop used to find the selections the user made within the database. It is during this step that the applicable results are saved in an array. Note that the database takes about 15 seconds to load.
[]Next (and this is important), the database is set to null for garbage collection. All event listeners are removed, yada yada yada.
[/LIST]
And that’s how the program works. Now for my question:
When the user wants to change his or her selection, he or she activates the options menu. Once the user is finished making changes, he or she clicks an OK button. This causes the entire database to reload - only this time it takes less than 2 seconds!!!
This is great, of course, because a 15 second wait time would be very annoying if it had to be done each time the user made any selection changes. But my question is why does this work so well?!?!
The database was garbage collected, wasn’t it? I assume so because performance would be incredibly slow if it were carrying a 12MB XML file around…
Does it become part of virtual memory? Is it still in the heap or the stack?
I would really like to understand the mechanics of this so that next time something like this is needed, I don’t have to just hope for the best.
Hopefully no code is needed for you to follow me - it is over 10,000 lines.
Let me know what all you genius people think!