Solved

How to allocate huge amounts of memory?

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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
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…
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.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

751 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