If by "memory usage" you mean Mem Usage column in Task
Manager then the "shrinking" you see is probably not realted
to garbage collection or CLR at all. It's caused by the OS
trimming your working set when it needs physical memory
for other purposes. Search google archives of this newsgroup
for "working set" and you'll find more info.
To confirm this theory, use perfmon to collect these counters:
process\private bytes
process\working set
..net clr memory\# bytes in all heaps
If only working set shrinks but Private Bytes and Bytes in all Heaps
are stable then it's working set trimming in action.
[quoted text, click to view] "Peter de Vroomen" wrote:
> Hi,
>
> I have built a server application in VS.NET 2003. This application is a
mix
> of managed and unmanaged code (don't know if this has anything to do with
> it). It uses I/O Completion Ports with thread-pooling to service
> client-requests.
>
> Now, when the server is running and servicing requests, the memory usage
> gradually gets larger and larger, say at the rate of about 8Kb per second.
> Until I decide to do something on the system like start a program. The
> memory usage then shrinks dramatically, at the cost of a lot of
> harddisk-rattling. I have seen the memory usage gradually grow to 56MB
over
> a few days and then shrink to 5MB with about 10 seconds of
> harddisk-rattling. Apparently the large memory footprint of 56MB was
caused
> by memory fragmentation, which Windows decides to garbage collect at some
> time.
>
> The problem now is that during shrinking of the memory/garbage collection,
> the server randomly denies requests from clients. Most clients get
serviced,
> but some simply get denied, or the server returns some error to them
(which
> has to do with timeouts). Apparently, the shrinking of the memory
> temporarily halts some or all of the threads in my server.
>
> What can I do about this? Can/should I force garbage collection every so
> often (say, every 15 minutes)? Or is there a way to make sure the memory
> doesn't get fragmented (other than keep all buffers as much the same size
as
> possible to promote memory reusage)?