Solved

How to allocate huge amounts of memory?

Posted on 2000-02-16
3
242 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Need Help INsttalling wget on Mavericks OS X 3 90
Folder Comparison 12 53
string initialization in java 11 109
Path of Workbook 3 59
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…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
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.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

930 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now