Solved

How to prevent using virtual memory

Posted on 2000-03-23
2
292 Views
Last Modified: 2013-12-26
Dear All:
    I have to allocate large memory to do date transfer through SCSI equipment.I allocate memory through standard memory function and sometimes get the virtual memory.
    The SCSI action will crash the system using virtual memory.  
    Is there any method to prevent get virtual memory or to recognize how much physical memory is left in my application's heap So that I can allocate memory smaller than that size
   Thank In advanced

Best Regards
Te-Lieh
.    
0
Comment
Question by:TeLieh
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
2 Comments
 
LVL 4

Expert Comment

by:Alex Curylo
ID: 2651868
Well, that's a start, but that's not going to stop your crashes by itself. The real trick to watch out for here is that other applications or the System might cause a page out your buffer behind your back, even if you are careful about physical memory size. What you should do is around your sensitive calls call

FUNCTION HoldMemory (address: UNIV Ptr; count: LongInt): OSErr;

to ensure that your buffer is actually in RAM until you call UnholdMemory().

Note that this is not just a good idea, it's the LAW. The VM chapter of IM says

"During the time that the Macintosh is handling a page fault, it is critical that no other page faults occur. Because the system performs no other work while it is handling a page fault, only code that runs as a result of an interrupt can generate a second page fault. For this reason, you must call the HoldMemory function on buffers or code that are to be referenced by any interrupt service routine. You must call this function at noninterrupt level because the MemoryDispatch calls may cause movement of logical memory or physical memory and possible I/O."

Your SCSI read buffer almost certainly is referenced by an interrupt service routine. And that would explain your crashes quite nicely :)

I strongly suggest you read through the Virtual Memory chapter of Inside Macintosh, which documents the above and probably lots of other stuff you should know, found on the Web at

http://developer.apple.com/techpubs/mac/Memory/Memory-151.html

Now, as for the actual question you asked, that's easy, just call Gestalt(), I'm sure you've run into that routine already, with the gestaltPhysicalRAMSize selector.
0
 
LVL 4

Accepted Solution

by:
Alex Curylo earned 75 total points
ID: 2651871
Bah. That last was an ANSWER, not a COMMENT. Stupid default forms. Read that and then accept this if that's good enough for you, please :)
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question