Please consider a donation to the Higher Intellect project. See https://preterhuman.net/donate.php or the Donate to Higher Intellect page for more info. |
How to Make Applications RAM Doubler Aware
Applications that object to the presence of virtual memory will also object to RAM Doubler being installed. This is because the gestaltVMPresent call will return True if RAM Doubler is present. Generally, it is not likely that RAM Doubler will cause any problems for your application, since it behaves differently than virtual memory and does not normally use VM techniques (using disk storage for memory) to double the memory available. Fortunately,it is possible to distinguish RAM Doubler from System 7 virtual memory by doing a check of the Gestalt selector 'vmem' and looking for a response of 'RaM2'.
What Your Program Needs to Check
If your program currently checks Gestalt to see if virtual memory is present, you will need to add a few lines of code to your program to determine if the result of the gestaltVM Present means that Virtual Memory or RAM Doubler is present.
The following C code contains two functions. The first, VMActive, checks to see if virtual memory is present. You probably already have similar code in your application, but we include the sample here for consistency and completeness. The second function, WhichVMIsInstalled, checks to see if RAM Doubler is present.
Boolean VMActive(void) { long response; return (GetOSTrapAddress(_Gestalt) != GetToolTrapAddress(_Unimplemented) && Gestalt(gestaltMAttr, &response) == noErr && (response & (1<<gestaltVMPresent))); } enum { kNoVM = 1, kSystem7, kRAMDoubler }; static short WhichVMIsInstalled() { long vmSignature; if (!VMActive()) { return kNoVM; } else { if (Gestalt('vmem', &vmSignature)) == norr && vmSignature == 'RaM2') { return kRAMDoubler; } else { return kSystem7; } } }
Why does RAM Doubler say VM is on?
In case you're wondering why RAM Doubler claims VM is on, the answer is simple: many programs, and in particular many hard disk drivers, assume that if they are not running VM, that:
- The translation between logical and physical memory does not change.
- There is no reason not to grab all available MultiFinder memory if needed.
- The performance penalty for accessing a random location in RAM is predictable.
- There is no need to "hold down" memory.
Since RAM Doubler uses the MMU to dynamically re-map memory, all of these assumptions break under RAM Doubler, so it is important that most applications operate in the same way under RAM Doubler as they would under VM. For more information, see the Inside Macintosh: Memory book.