I wrote two apps and its sitting on my server. Between the two of them they use up 1/3 of my ram. When i do a fresh run they only take up 1/8 of my ram which is a pretty drastic change. Is there a way i can tell mono or use .NET to say run the GC every hour even if it thinks it doesnt need it? I dont know if most of this ram is used as a sqlite cache but i really dont need it.
2 Answers
Not completely related to question header, but related to the description. You can force a collection using GC.Collect(). You can also try using second mono's garbage collector, that is sgen (just run mono-sgen instead of mono).

- 46,413
- 6
- 36
- 47
-
As Edward Thompson said, problem is usually not there (mean GC.Collect, not the sgen which in fact *can* resolve some problems with Boehm collector). However it was what asked. – konrad.kruczynski Oct 07 '11 at 19:35
-
Although i did ask how to collect unfortunately today after letting it run for hours i saw that it didnt help – Oct 08 '11 at 16:07
Calling System.GC.Collect()
is scary business and almost always unnecessary... The GC is really very good. It's well written. It performs both correctly and efficiently most of the time. Forcing a GC run is often a bandaid over other problems.
How are you determining the amount of memory used? Ie, has it merely allocated that much space? Or is it actually using that much space? Is any of it swapped? Etc.
Have you used mono profiling yet to determine what's going on?
You mention the SQLite cache: are you certain that you're removing all the roots to the objects you're caching? Without this, no amount of GC will ever free that memory.

- 1
- 1

- 74,857
- 14
- 158
- 187
-
In my case literally have a loop which sleeps when its done and it pings my websites and other pages, scans of data, logs it (or logs if its down) then sleeps and repeats. Everything is allocated/destoried in the loop. Theres no list or root data to clear out. maybe theres something i am using in a library (html agility) but i have no idea. As a temp solution i just restart the process every 2hours. How might i profile it if the program never finish executing? I dev'd it on windows. My windows, dev linux and server are all very different environments. – Oct 08 '11 at 02:45
-
I decided to give the profiling a try and 1) Since its never ending i need a way to stop it so i tried ctrl+c and that doesnt allow the profile data to show. 2) I dont know how to recreate the memory issue other then running it for hours and hours... – Oct 08 '11 at 02:55