The problem I have is that I want to view the same *size*
portion every time I map, let's say 700Mb. This also works,
for a while.
After my program has been running for a long while, this will
at some point, fail. I know I'm not leaking memory (I use
Purify). The problem is that the memory address space is
becoming too fragmented.
What happens is, I'll call UnmapViewOfFile (), and also, while
cleaning up, free lots of other things I've allocated. I then
go back to MapViewOfFile, trying to map another chunk. But in
the mean time, an allocation has occured within the space I
was using, so MapViewOfFile can't find a contiguous 700Mb slice,
and *poof*.
I've used VirtualQuery to dump the locations and state of the
2Gb address space, and I can see that this is exactly what is
happening: what used to be my nice 700Mb slice has a 4k block
whacked out of it.
What I'd *like* to do, is reserve that 700Mb at program startup.
VirtualAlloc() alomst seems like the function to get me there,
but, unfortunately, you can't pass reserved but not committed
pointers from VirtualAlloc() to MapViewOfFileEx ().
Alternatively, I'd like to be able to atomically remap the file,
but there's no call to do that.
What I *am* doing for now is trying to Unmap() just before I
Map(). This is stopgap, and in-elegant, because my program is
multi-threaded, so while this "sort of" works, it's not bulletproof.
Anyone have any clues?
--
Eric J. Holtman (Jaeger T. Cat)
http://www.ericholtman.com
PGP Key: http://www.ericholtman.com/pgp.txt
Niven's Law 1a: Never throw shit at an armed man.
Niven's Law 1b: Never stand next to a man throwing shit at an armed man.
______________________________________________________________________
Posted Via Uncensored-News.Com - Still Only $9.95 - http://www.uncensored-news.com
With NINE Servers In California And Texas - The Worlds Uncensored News Source