[comp.sys.mac.programmer] OpenResFile size

ml10+@andrew.cmu.edu (Michael A. Libes) (12/16/89)

I've been trying to minimize the memory requirements of the new version
of my _Launch program and I have been successful in all but one area.

To get an icon from an application, I call OpenRFPerm(...fsRdPerm) on
that application.  The resource map, and other Resource Manager memory
structures, take up a HUGE amount of memory.  For example, getting the
icon from THINK C requires 82K of contiguous space in my heap.

Is there are way to tell the Resource Manager to take up less space?
If not, can I request another (temporary) heap zone?
Or, how can I make the Resource Manager use some space which I get from
a Multifinder Temporary NewHandle call?

Any suggestions would be much appriciated.

    - Lunarmobiscuit

ml10+@andrew.cmu.edu (Michael A. Libes) (12/16/89)

I found the answer.  Do a SetResLoad(TRUE) before calling OpenResFile
then a SetResLoad(FALSE) after.
The reason OpenResFile is a memory hog is that all resource marked as
"Preload" are loaded in when the resource file is opened.  I can now
open THINK C in 4.5K instead of 52K.

    - Luni

andyp@gvgpvd.GVG.TEK.COM (Andy Peterman) (12/17/89)

In article <IZWHArm00WBL41mEs6@andrew.cmu.edu> ml10+@andrew.cmu.edu (Michael A. Libes) writes:
>To get an icon from an application, I call OpenRFPerm(...fsRdPerm) on
>that application.  The resource map, and other Resource Manager memory
>structures, take up a HUGE amount of memory.  For example, getting the
>icon from THINK C requires 82K of contiguous space in my heap.
>
>Is there are way to tell the Resource Manager to take up less space?

Try using SetResLoad(false) before your Open call and then
SetResLoad(true) immediately after it.  This will stop any preloadable
resourses from automatically being loaded in.  The resource map,
however, will still be loaded.  Hope this helps...

	Andy Peterman

tim@hoptoad.uucp (Tim Maroney) (12/18/89)

In article <gZWM5Va00UhBE1mm0j@andrew.cmu.edu> ml10+@andrew.cmu.edu
(Michael A. Libes) writes:
>I found the answer.  Do a SetResLoad(TRUE) before calling OpenResFile
>then a SetResLoad(FALSE) after.

This is backwards.  I'm sure it was just a typo, but since leaving resload
false can crash the system, I dind't want anyone naively trying this in
the reversed version.  Call SetResLoad(false) before OpenResFile and then
call SetResLoad(true) after OpenResFile.
-- 
Tim Maroney, Mac Software Consultant, sun!hoptoad!tim, tim@toad.com

"Now hear a plain fact: Swedenborg has not written one new truth: Now hear
  another: he has written all the old falshoods.
 And now hear the reason.  He conversed with Angels who are all religious, &
  conversed not with Devils who all hate religion..."
    - Blake, "The Marriage of Heaven and Hell"