Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

How to allocate huge amounts of memory?

Posted on 2000-02-16
3
Medium Priority
?
251 Views
Last Modified: 2013-12-26
Hi,
I need to allocate some huge mem blocks (sometimes bigger than physical memory).
But for speed reasons it should be taken from the SysHeap, if possible.

My 1st solution:
- Just call handle=NewhandleSys() and test the return value.
- Problem: if(handle==NULL) then I can see in the computer->AboutBox the the MacOS allocated some mem but it's unable to free these internal blocks (OS-RAM boosted from 30MB to 100MB, only reboot solves the problem)! Why?

My 2nd solution:
- Check first. So I ask the OS via MaxBlockSys(size) - but the answer is always something like 300KB until I made a successful call to NewHandleSys() - how to get the max. allowed size for NewHandleSys()??

I'm getting really confused about that (sorry, but under WinNT I just say malloc() and that's all...).
I'd be really glad if I could get a short explanation about the philosophy behind that. Or a good link.

Thank you very much ion advance!
chris
0
Comment
Question by:charlass
  • 2
3 Comments
 
LVL 4

Accepted Solution

by:
Alex Curylo earned 150 total points
ID: 2528107
I think you've probably run into Memory Manager bugs. See, NewXXXSys() calls are meant for *small* allocations, like made by an extension or an interrupt task. They are just not meant to be used for large allocations. MaxBlockSys() is probably returning the largest value the System engineers want to support or something like that. But don't worry about the details, stop using those calls :)

The calls you *should* be using when you want memory outside your application heap are TempNewHandle() to get it and TempMaxMem() to find the largest block available. These are documented in Inside Mac:Memory. Links to this and to memory-related tech notes are on the Web at

http://developer.apple.com/techpubs/macos8/OSSvcs/MemoryManager/memorymanager.html

Note that the system memory allocation issue is specifically addressed in QA ME 08 at

http://developer.apple.com/qa/me/me08.html
0
 
LVL 1

Author Comment

by:charlass
ID: 2530132
Thank you, Alex.
I was using the TempMem already but I've the feeling that also smaller TempMemBlocks are taken from the hard disk - "how slow" was my first impression. Right or wrong?
Anyway, thanx especially for the 2nd link.
0
 
LVL 4

Expert Comment

by:Alex Curylo
ID: 2531791
Well, if you have virtual memory on and are using more than physical RAM, *some* of it has to be on the hard disk and free memory is a bit more likely to be there when you first allocate it, I suppose.

But other than that, temp mem is just the same as any heap allocation.
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
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.
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …

824 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