Solved

How to allocate huge amounts of memory?

Posted on 2000-02-16
3
246 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 50 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: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone 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

Suggested Solutions

Title # Comments Views Activity
Separate into files by filename 12 87
viewing source code from eclipse 13 110
haveThree challenge 22 122
Problem to open Excel file 15 179
Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
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.
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

821 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