Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum

View Single Post
Old 09-15-2010, 10:43 PM   #13 (permalink)
JoeKun
Registered Member
 
Join Date: Sep 2010
Location: San Francisco
Posts: 1
JoeKun is on a distinguished road
Default A solution that works to compute MD5 hash of large file with low memory consumption

Quote:
Originally Posted by edster View Post
Time to circle back on an issue I thought was long resolved. Back when I first did this, it seemed like the explicit init and release was doing the trick. However, I'm getting some crash reports from an old iTouch user where they are running out of memory.

So now I'm testing again and I'm seeing a huge spike in memory usage when its calculating the hash. Not doing the MD5 check, my app stays around 9.5 - 11MB for its entire life, while downloading as much as 200-300MB in the background. If I enable the MD5 check, memory will shoot up as high as 60MB or so which will kill old devices. Even after the spike, the memory seems to be creeping up over time even though 'Leaks' is not showing any memory leaking. So regardless of the memory spike, I think the hash routines are not freeing some allocated memory.
Even though you use a non autoreleased object called fileData, you still have an autoreleased object there:

Code:
NSData *fileData = [[NSData alloc] initWithData:[handle readDataOfLength:4096]];
Remember that the result of -readDataOfLength: was allocated and autoreleased. So, in reality, your solution is worse than the one proposed by smithdale87, because you end up allocating the same objects, plus one.

I came up with an implementation that really works. I wrote an article about this efficient way to compute the MD5 hash of a large file.

I hope this helps.
JoeKun is offline   Reply With Quote
 

» Advertisements
» Online Users: 394
15 members and 379 guests
alexdesuja, chemistry, Chickenrig, dansparrow, EvilElf, hrushikeshaddon, iconomania, ipodphone, jimmyon122, larhondaxzcw, linkmx, Mnadeep, SamorodovAlex, tomtom100, zhaoningmei
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,585
Threads: 94,083
Posts: 402,775
Top Poster: BrianSlick (7,990)
Welcome to our newest member, alexdesuja
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 01:27 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.