Thread View: rec.games.programmer
2 messages
2 total messages
Started by Oliver Jones
Fri, 19 Jan 1996 13:52
Watcom and Available Memory
Author: Oliver Jones
Date: Fri, 19 Jan 1996 13:52
Date: Fri, 19 Jan 1996 13:52
13 lines
1014 bytes
1014 bytes
(Email replies please) Hi. I have Watcom C++ v10 and I need a way to find out how much free RAM is left available to allocate. I've played with _heapwalk() and memaval etc and they only report about 3k available. I have 32mb of RAM. I'm doing this with DOS/4GW and wpp386. If anyone knows a way of reporting the entire FREE RAM space I'd be greatful if they were to share it with me. Preferably I'd like to know if there is a standard way of finding the entire free "core" area under any C or C++ system. I there is none i think it's a gapping hole in the standard. Ciao, Oliver Jones
Re: Watcom and Available Memory
Author: Jeff Petersen
Date: Fri, 19 Jan 1996 16:59
Date: Fri, 19 Jan 1996 16:59
45 lines
2979 bytes
2979 bytes
> Hi. I have Watcom C++ v10 and I need a way to find out how much free >RAM is left available to allocate. I've played with _heapwalk() and >memaval etc and they only report about 3k available. I have 32mb of >RAM. I'm doing this with DOS/4GW and wpp386. If anyone knows a way >of reporting the entire FREE RAM space I'd be greatful if they were to >share it with me. Preferably I'd like to know if there is a standard >way of finding the entire free "core" area under any C or C++ system. >I there is none i think it's a gapping hole in the standard. Better get used to not knowing; it is a bad habit to get into. You may be able to find a way to get the system to report that it has 10mb free, but if you were to try and allocate 10 - 1mb chunks something would probably fail due to fragmentation. Also, newer operating systems like NT virtualize stuff whether you like it or not. I wrote a sort program once that wanted to use all available memory (under NT) and at any given time, a large portion of the memory is in use, but can easily be freed up by either throwing it away (cached stuff) or swapping it to disk. You sort of need to ask yourself where the line is when you start forcing the OS to swap stuff out that it will need real soon or maybe even swapping your sort buffers out (largely defeating the purpose). What happens when the user opens another application after your application has taken everything -- you start swapping again. In the case of the sort program, I asked the system how much total real memory there was (32mb and this case) and told my sort program (which is designed to have primary control of the machine while being ran) to take TOTAL - 8mb (or 24mb). All of that said, under DOS4GW (with VM off) I wrote a little function that tried to allocate 64mb and then kept shrinking the request (256k at a time) until it succeeded. It then freed the chunk and told me what it could get. This does not give you total available, but does give you the largest chunk you might be able to get. If you do it early in the program and remember the number, it will give you a pretty good indication of how much you have to work with total (leave a little slack for fragmentation (particularly if you are doing large allocations)). BTW, if anybody is doing large allocations (>512k) under WindowsNT I have an interesting bug that you might want to know about, if anybody is interested drop me a note. Jeff Petersen Artificial Software jeffp@itsnet.com
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads