PKImagePickerDemo icon indicating copy to clipboard operation
PKImagePickerDemo copied to clipboard

Photo Taking Issue relating to Memory

Open philgrida opened this issue 11 years ago • 19 comments

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.

philgrida avatar Jul 30 '14 04:07 philgrida

Will take a look at it .

pavankris avatar Jul 30 '14 12:07 pavankris

Thank you

philgrida avatar Jul 30 '14 23:07 philgrida

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

pavankris avatar Jul 31 '14 00:07 pavankris

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.

philgrida avatar Jul 31 '14 00:07 philgrida

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.

pavankris avatar Jul 31 '14 01:07 pavankris

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

philgrida avatar Jul 31 '14 01:07 philgrida

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.

pavankris avatar Jul 31 '14 02:07 pavankris

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 ?

philgrida avatar Jul 31 '14 03:07 philgrida

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 ??

pavankris avatar Aug 01 '14 01:08 pavankris

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.

philgrida avatar Aug 01 '14 01:08 philgrida

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

pavankris avatar Oct 20 '14 18:10 pavankris

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

MobileMon avatar Oct 22 '14 17:10 MobileMon

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.

philgrida avatar Oct 23 '14 00:10 philgrida

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

MobileMon avatar Oct 23 '14 21:10 MobileMon

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

philgrida avatar Oct 23 '14 23:10 philgrida

reopening this .

pavankris avatar Oct 24 '14 03:10 pavankris

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.

fayhot avatar Jan 02 '15 17:01 fayhot

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

pavankris avatar Jan 02 '15 20:01 pavankris

I'm having the same issue.

Any updates on this?

milsirhc avatar Sep 02 '15 12:09 milsirhc