Solved

How to allocate huge amounts of memory?

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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Unix / Linux grid computing 5 127
Macro to save highlighted rows as a separate file 5 38
has77  challenge 9 67
post4 challenge 28 83
Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
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.
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

706 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

14 Experts available now in Live!

Get 1:1 Help Now