According to the MacPerl documentation, ReleaseResource returns 1 on failure. Hence the example given in the .pod files: if ( ReleaseResource($HANDLE) ) { # error occurred } else { # proceed } However, for some reason I seem to be getting the opposite behavior--it seems to return 1 on success, zero on failure. See the code example at the end of the document for an example--the code is simply the "resources.t" file included with MacPerl, hacked up with three attempts at ReleaseResource--it claims that the first attempt fails, while both of the second two fail. Looking at ZoneRanger seems to indicate that MacPerl releases the resource in the first case, contradicting the apparent failure. It also indicates, however, that MacPerl creates a NEW handle every time it calls ReleaseResource--I know very little about the Resource Manager, but this seems odd to me (but I also know very little about ZoneRanger, so I may be misreading it.) ZoneRanger also seems to show that all of the "extra" handles created by the calls to ReleaseResource finally go away when the resource fork of the file is closed. My main problem is that I have a memory leak _somewhere_ in my code (I can process about 100 files before MacPerl hits the ceiling and crashes), and I think it has to do with the resources, but I can't quite tell. I can't tell where my problem lies, but this behavior of ReleaseResource seems funny--what am I doing wrong? I've looked around the archives for any other code examples using resources, but didn't find any--anybody have anything working I could look at (some code in which you are sure you are reading and releasing resources successfully?) thanks, Dan Herron UC San Diego Dept. of Cognitive Science herron@cogsci.ucsd.edu La Jolla, CA 92093-0515 ------------------------------------------------------------------------------ Perl -Sx "{0}" {"Parameters"}; Exit {Status} #!perl # # Resources.t - Demonstrate Resources # use Mac::Resources; use Mac::Memory; $res = OpenResFile($ARGV[0]) || die "$^E"; print "Types: ", Count1Types(), "\n\n"; for ($types = Count1Types(); $types; --$types) { $type = Get1IndType($types); print "Resources of type $type: ", Count1Resources($type), "\n"; for ($rsrcs = Count1Resources($type); $rsrcs; --$rsrcs) { $rsrc = Get1IndResource($type, $rsrcs); ($id, $type, $name) = GetResInfo($rsrc); printf("%4s %6d %s\n", $type, $id, $name); print "First try: "; if ( ReleaseResource($rsrc) ) { # error occurred print "error on releaseResource\n"; } else { # proceed print "releaseResource worked fine\n"; } print "Second try: "; if ( ReleaseResource($rsrc) ) { # error occurred print "error on releaseResource\n"; } else { # proceed print "releaseResource worked fine\n"; } print "Final try: "; if ( ReleaseResource($rsrc) ) { # error occurred print "error on releaseResource\n"; } else { # proceed print "releaseResource worked fine\n"; } } } CloseResFile($res);