Memory efficient way to get image metadata?
Memory efficient way to get image metadata?
- Subject: Memory efficient way to get image metadata?
- From: email@hidden
- Date: Mon, 3 Aug 2009 20:23:27 +0000 (UTC)
Hi
I wrote an image catalog application that scans files on a Windows server, extracts certain image file info (like mod date, name, width, height and color mode) and writes this info to a database. During testing, in a real environment, the app started crashing and I narrowed the problem down to the following line of code:
NSImage *image = [[NSImage alloc] initWithContentsOfFile: inPath];
If I comment that out, the app never crashes, but I also never get the width, height and color info. I used the "instruments" app to watch memory and during an initial scan of a directory tree, my app does use a lot of memory (50-60 mb) but no where near the Machine's limit of 2 gb. It seems like the OS can't keep up with all the image loading and freeing, and just thrashes memory so badly that at a certain point, it just refuses to allocate any more.
I set a breakpoint at " malloc_error_break" as the run log suggested, but it always leads back to the method containing the above line.
Is there some way (other than rolling my own image readers) to just get the metadata from a file rather than having to load the entire thing? A third party class that would be something like "NSImageInfo" (if Apple had written such a class)
Any help greatly appreciated.
If I comment that out, the app never crashes, but it also never gets the image info I need.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden