Thanks everybody for your kind helps.
I'm so happy that all of you welcome me warmly here.
On Wed, Jun 25, 2008 at 3:36 PM, Ken Thomases <[EMAIL PROTECTED]> wrote
>
>
> Also, in the pseudo-code you provide, the NSData objects will accumulate in
> the autorelease pool until some point after your "for" loop.  You can try
> using an autorelease pool inside the loop so that the NSData objects are
> released after each iteration.  You may just be exhausting memory.  For the
> case where you're not using NSData, the memory exhaustion might not happen
> since you're not storing the data twice in memory (once in the handle, once
> in the NSData), but would if there were twice as many resources.

Thanks Ken. I'm confusing that as the memory management rules say, I myself
did not take the ownership of the NSData objects. So, I'm not responsible
for relinquishing ownership of them?
On Wed, Jun 25, 2008 at 10:08 PM, Kyle Sluder <
[EMAIL PROTECTED] <[EMAIL PROTECTED]>> wrote:
>
>
> What is this "exe file" nonsense?  I don't have any files with the
> extension "exe" on my machine.  I'd wager you don't either.  Seems
> like you're a Windows programmer.  In that case I heartily recommend
> you read up on the differences between the way Windows executables and
> UNIX binaries function -- sometimes subtle.  Then read up on .app
> packages.

I meant the executable file inside the app package(under contens/MacOS/) not
the file with the extension .exe.
But you're right. I has just started to use Mac OS for 3 months :). I will
try to read up your suggested information.
On Thu, Jun 26, 2008 at 12:58 AM, Kai <[EMAIL PROTECTED]> wrote:

>
> On 25.6.2008, at 10:42, Tran Kim Bach wrote:
>
>  Thanks Ken and Kai for your very very quick responses
>> This is my first post in the list, I'm sorry for not clarifying my
>> problem.
>>
>> Actually, the program stopped at the mentioned line.
>> In console, it said something like:
>> objc[2144]: FREED(id): message release sent to freed object=0x17d1d0
>>
>
> Ok, this looks like a standard overrelease problem. You posted too little
> code to include the problematic point.
>
> Best to read up on Cocoas Memory Management Rules and make sure, that your
> Objective-C objects are not overreleased.

I did read it but maybe I did not get it all. Below is my entire code with
some unrelated codes removed.
I hope you can show me the way to get out of this problem. I'm totally new
to Programming in Mac OS.

        OSStatus error = noErr;

unsigned short pmResFile = 0;

NSString *resFile;

NSURL *url;

FSRef fsRef;

resFile = [textField stringValue]; // get resfile from a textField (for
example)

url = [NSURL fileURLWithPath:resFile];


 CFURLGetFSRef( (CFURLRef)url, &fsRef);

(void)FSOpenResourceFile( &fsRef, 0, NULL, (SInt8)fsRdPerm, &pmResFile);

short saveRes = CurResFile();

if (pmResFile > 0)

{

int i = 0;

int count = 0;

ResType resType;

                NSString *typestr = [comboBox stringValue];

memcpy((char *)&resType, (char *)[typestr cStringUsingEncoding:
NSUTF8StringEncoding], 4);

 UseResFile(pmResFile);

 count = Count1Resources( resType );

for (i = 1; i <= count; i++)

{

long sizeLong;

short resIDShort;

NSString *name;

NSNumber *resID;

ResType resType1;

Str255 nameStr;

NSString *type;

Handle dataHandle;

NSData *data;

 dataHandle = Get1IndResource( resType, i);

error = ResError();

if(error!=noErr)

{

NSLog(@"Reading resource error");

UseResFile(saveRes);

return;

}

GetResInfo(dataHandle, &resIDShort, & resType1, nameStr);

sizeLong = GetResourceSizeOnDisk(dataHandle);

HLockHi( dataHandle );

name = [NSString stringWithCString:&nameStr[1] length:nameStr[0] ];

type = [NSString stringWithCString:(char *) & resType1 length:4];

data = [NSData dataWithBytes:*dataHandle length:sizeLong ];

        resID = [NSNumber numberWithShort:resIDShort];

 if((type2 =='PREC')&&([resID intValue]== 302))

{

    struct PGControlRes pgControlRes;

memcpy(&pgControlRes,[data bytes], [data length]);

// more codes

}

HUnlock(dataHandle);

ReleaseResource(dataHandle);

}

UseResFile(saveRes);

}

CloseResFile(pmResFile);



Cheers,
Bachtk
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to