简体   繁体   中英

What will the effect of trimming my “working set” be on a system with no page file?

A customer is complaining that my program is using too much memory. However, after working with them for a while, I've realised that:

  1. They've turned off their page file (on their terminal services box).
  2. They're worried about the size of the "private working set" figure in task manager for my program.

So, my question is, if I just trim the size of the working set with EmptyWorkingSet() after my program has started up (it uses lots of memory during XML parsing but then deletes it, but the working set doesn't seem to go down) I can make the working set figure go right down. However, will this actually help the customer? I have a feeling this just means that the working set will be paged and I believe if you have the page file turned off, the working set is backed by real memory anyway....

Is it true to say that what task manager reports as "private working set" is really how much my program has new/malloced?

At least in a sense of standard terminology, "private working set" is the amount of memory your program has mapped that is not backed by files (the program executable, dlls, or manually memory-mapped files) on disk or other shared resources. If swap (paging) were enabled, it's the amount of swap space your program would occupy if it were entirely swapped out of memory.

I would agree with your management that you need to fix your bloated program. Turning off swap is a very sane decision for a customer with low-latency requirements. If your program is using 2GB of memory, perhaps you need to rethink whatever libraries you're using to represent XML data in memory.

You've noted that your working set goes up after new/malloc . This is because they ask the OS for memory. You've also noted that it does not go down after delete/free . This is because they don't return memory to the OS. On a normal, sane system, this is not a problem. The unused memory space for your process will end up in swap, untouched and out of RAM.

On this special box, you'd be better off to override operator new with a direct call to HeapAlloc and operator delete with a call to HeapFree . Do enable the low-fragmentation heap for Server 2003; it's already the default for 2008.

The private working set seems to be the virtual memory your program alone uses and needs, so I'm not sure that resetting is going to help you. I'd find out why your program is using so much memory, rather then trying to play around with the private working set.

Memory leaks?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM