pavankris / PKImagePickerDemo

Replacement for ImagePicker which also combines camera and album
MIT License
100 stars 28 forks source link

Photo Taking Issue relating to Memory #4

Open philgrida opened 10 years ago

philgrida commented 10 years ago

Hi

Thanks for the great library. I have noticed though that when if you Profile the app in Instruments (and select the Allocations template) and if you monitor the "All HEAP allocation" the app rises considerably (about 5-6MB) every time you take a photo. If you then take a quite a few photos, i.e. dozens the app eventually crashes since it has run out of memory. Do you know why this might be the case and can it be fixed ? It seems the memory is not subsequently released or freed.

Phil.

pavankris commented 10 years ago

Will take a look at it .

philgrida commented 10 years ago

Thank you

pavankris commented 10 years ago

I don't see happening do u have arc enabled ??

philgrida commented 10 years ago

Yes I am using just the default project you have provided which has ARC enabled. I haven't made any further modifications. Have you tried running it in Instruments using the Allocation template ? I just hooked up the project to a iPad (running iOS7) and the memory (heap etc) was increased every time a photo was taken but it was never reduced.

pavankris commented 10 years ago

screen shot 2014-07-30 at 9 32 05 pm

This is what i get , i don't see going the way u mentioned it.

philgrida commented 10 years ago

When I start Instruments the "All Heap and Anonymous VM" Overall Bytes starts at 4MB about but after say a dozen camera shots it has increased to over 570MB. The app will crash after a few more pictures being taken. after - 12 shots start

pavankris commented 10 years ago

Thats not live bytes rite ? . But overall bytes is not much useful here, and it is certainly not leaking memory, so app crashing by running out of memory little doubtful.

philgrida commented 10 years ago

Hi, Yes it's not live bytes but overall for the app it will crash after a few camera shots are taken. Have you tried a few camera shots and see it increase ? Do you know why that might be the case ? Is there a cache of some type with the AVCaptureSession or CMSampleBufferRef that is used which can be cleared ?

pavankris commented 10 years ago

I didn't crash for me, i tried like 20 or so. The CMSampleBufferRef , i think allocates memory for every shot , If there is cache won't live bytes also increase ??

philgrida commented 10 years ago

Thanks. Did you notice the heap being increase though ? Eventually it would crash. I don't think the live bytes would increase necessarily as HEAP is a different part of memory.

pavankris commented 10 years ago

I guess this issue might because of strong reference of delegate. Should be fixed now. Give it a shot.

MobileMon commented 10 years ago

I too have this issue and changing the delegate to assign does not fix it!

philgrida commented 10 years ago

Yes I can verify that the delegate fix does not fix the memory issue relating to HEAP issues resulting in the app to crash after a few photos are taken.

MobileMon commented 10 years ago

Here's the issue: the heap will go down as expected if you wait enough time in between taking pictures. However taking pictures rapidly in a row prevents memory from releasing fast enough so eventually the app will crash. We need a more aggressive approach to recycling the memory....I'll follow up if i think if anything. Please do the same

philgrida commented 10 years ago

Yes that is exactly the issue. Will post anything if I find a good mechanism.

pavankris commented 10 years ago

reopening this .

fayhot commented 9 years ago

i met the same issue too. when taking photo, the memory suddenly increase, and then the app may crash a moment later. however, choose picture from the album is ok.

pavankris commented 9 years ago

can u please create a small project and put it in github , i will test this out.

milsirhc commented 9 years ago

I'm having the same issue.

Any updates on this?