On the web application, I am using a lot of dictionaries, to store a lot of information per user-session. For each session, the server increase the memory,around 10MB. When I execute the command dictionary.Clear(), I did not seen, the server to free memory for the specific session. The same, if the session is lost/close. When, the server will clean up the memory? The same thing happens, if I use classes/collections/arrays and set them to nil or redim them (arrays). Again, the server does not frees any KB of usage memory . Can someone to explain, how the system is clean up the memory ? It creates a problem, because the system does not cleans the memory and all the time increase it, with the connections.
It depends on the OS, but for the most part garbage collection happens when the OS gets around to it.
That being said, you must be careful not to create circular references. We went through and cleaned up a lot of memory leaks last fall, and I’m pretty confident that they’ve all been cleaned up now.
I am working on Win7 64b and I made the same tests on dictionaries and collections on web and desktop application. On desktop application, immediately when you assign Nil on classes or execute dictionary.clear(), the application used memory decrease. But on web application, exactly with the same data on classes and dictionaries, nothing happens when you assign to nil. Both testing on Win7. For the web programming, do I need to do something more, so the garbage collection to execute immediately ?
The classes handle around 20000 records and store on dictionary.
Exactly the same data loaded on web and desktop application. I was waited around 20 min (sessions closed on 1 minute). You can make a simple test with a class with 3 string properties, create a dictionary property on webform, make a loop of 10.000 class instances and save them on dict property. Open 3-5 tabs on your IE/Firefox, you will see the memory of debug web application to increase … make a button to kill some of the open sessions, but no garbage collection executed to clean the application memory. Copy/paste on desktop application, loop the class for 100000 and then clear the collection. App memory comes back on the same size as before started to load the classes on dictionary. Garbage collection works on desktop…
For web testing, I executed 1000 rest calls from 3rd system and on HandleSpecial event, for each call I created a new class with some data. When it returned back the class data (exit from procedure), it supposed that it will given back the memory that it used for the class of each rest call. When the application took 1GB of memory, I stopped it …
@Antonis Vakondios
The best thing you could do for us is to create a bug report in Feedback and attach the sample app that you are describing above. The only reason I ask is that instructions are up for interpretation. I’d like to see the exact conditions that are causing this.
Did you try your code in a Console app, like I asked?