1

I am developing a small application with Custom Camera control .

Its working verry well with all functionality without any Leak in Memory

But when i try to access camera more than 8-9 times, application crash ...

I checked with Performance tool but there is no memory leak there ,,, also total Live Bites is 4.96 MB only

I am getting following error ...



Thread 0 name:  Dispatch queue: com.apple.main-thread
Thread 0 Crashed:
0   libsystem_kernel.dylib          0x35443a1c __pthread_kill + 8
1   libsystem_c.dylib               0x320e93b4 pthread_kill + 52
2   libsystem_c.dylib               0x320e1bf8 abort + 72
3   libstdc++.6.dylib               0x31d5ca64 __gnu_cxx::__verbose_terminate_handler() + 376
4   libobjc.A.dylib                 0x3011006c _objc_terminate + 104
5   libstdc++.6.dylib               0x31d5ae36 __cxxabiv1::__terminate(void (*)()) + 46
6   libstdc++.6.dylib               0x31d5ae8a std::terminate() + 10
7   libstdc++.6.dylib               0x31d5af5a __cxa_throw + 78
8   libobjc.A.dylib                 0x3010ec84 objc_exception_throw + 64
9   CoreFoundation                  0x3170e1b8 -[NSObject(NSObject) doesNotRecognizeSelector:] + 96
10  CoreFoundation                  0x3170d642 ___forwarding___ + 502
11  CoreFoundation                  0x31684178 _CF_forwarding_prep_0 + 40
12  UIKit                           0x32a37118 -[UIViewController purgeMemoryForReason:] + 20
13  UIKit                           0x32a37146 -[UIViewController didReceiveMemoryWarning] + 10
14  UIKit                           0x32a3715c -[UIViewController _didReceiveMemoryWarning:] + 8
15  Foundation                      0x3632117c _nsnote_callback + 136
16  CoreFoundation                  0x316d9208 __CFXNotificationPost_old + 396
17  CoreFoundation                  0x31673ee4 _CFXNotificationPostNotification + 112
18  Foundation                      0x3631e5cc -[NSNotificationCenter postNotificationName:object:userInfo:] + 64
19  Foundation                      0x363201ba -[NSNotificationCenter postNotificationName:object:] + 18
20  UIKit                           0x32a0d35a -[UIApplication _performMemoryWarning] + 42
21  UIKit                           0x32a0dd7c -[UIApplication _receivedMemoryNotification] + 120
22  UIKit                           0x32a0b500 _memoryStatusChanged + 36
23  CoreFoundation                  0x316d9d62 __CFNotificationCenterDarwinCallBack + 18
24  CoreFoundation                  0x316d6bd8 __CFMachPortPerform + 204
25  CoreFoundation                  0x316e1a90 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 20
26  CoreFoundation                  0x316e3838 __CFRunLoopDoSource1 + 160
27  CoreFoundation                  0x316e4606 __CFRunLoopRun + 514
28  CoreFoundation                  0x31674ebc CFRunLoopRunSpecific + 224
29  CoreFoundation                  0x31674dc4 CFRunLoopRunInMode + 52
30  GraphicsServices                0x36497418 GSEventRunModal + 108
31  GraphicsServices                0x364974c4 GSEventRun + 56
32  UIKit                           0x328e2d62 -[UIApplication _run] + 398
33  UIKit                           0x328e0800 UIApplicationMain + 664
34  Imagepicker                 0x000020ec main (main.m:14)
35  Imagepicker                 0x000020a0 start + 32




Live bites are less than 5 MB still i am getting this crash ... For 3G and 3Gs , it became more wired ... It crash so much for them ... and more often ...

Any help ?????

Darshan Shah
  • 61
  • 2
  • 8
  • Please check the maximum allocation,( besides live bytes). also check whether you recover the allocation done while opening camera view and closing it, does the allocation adds on? – Ravin May 12 '11 at 04:08
  • Hi Ravin ... Thanks for reply ... I do check about "Overall Bytes" and "Live Bytes" .... Live Bytes does decrease as per i release it .. But Overall Bytes does increase ... But I believe Overall Bytes are total allocation but Live Byts are the real bytes which are for Application ... – Darshan Shah May 13 '11 at 16:04

1 Answers1

0

I am having a similar problem with a camera app that I have built. I am getting lots of low memory warnings. Are you watching those?

As a stopgap measure while I determine the problem I have put in something like this:

- (void)didReceiveMemoryWarning {
    NSLog(@"memory problem!!!!!!!!!!");
    NSString *errorString = [NSString stringWithFormat:@"There isn't enough memory to run this app right now.  You should quit some apps and try again."];
    UIAlertView *errorAlert = [[UIAlertView alloc] initWithTitle:@"Low Memory Warning" message:errorString delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
    [errorAlert show];
    [errorAlert release];    
    [super didReceiveMemoryWarning];
}
Mark Chackerian
  • 21,866
  • 6
  • 108
  • 99
  • Hi Mark !! Thanks for your reply !! I thought same way before .. but many other application with Camera can run at that point .. I mean other application like Photobooth and all have Camera control also ... They can run at the same point .. Than why i am having this problem !?? so i feel like i am doing something wrong here !!! Did you find out any other solution ? – Darshan Shah May 13 '11 at 22:58
  • At some point in the future I will be going through my app and trying to reduce memory use -- if I find anything camera specific I will post here. – Mark Chackerian May 16 '11 at 18:08
  • Any Help ? I am still stuck :( – Darshan Shah May 24 '11 at 17:19
  • I haven't gotten back to this yet. I am thinking that I am going to have to make the memory use a little more dynamic. I have a an array of objects that is loaded into memory that is being dumped on low memory warnings. I may need to check if the images are not in memory and reload them one at a time. – Mark Chackerian May 24 '11 at 21:39
  • Thanks for reply , I understand that its totally memory related ! But at the same place .. How much memory can your application have is not so sure ! By mean is , My application is mostly crashing cause of lots of application opens on backhand .... Now if i try to reduce use of memory by other component in my application .. still i can not control Camera control for using required memory ,,, So i feel like its all depends on application opens on back side.... !! Is that i am right ? – Darshan Shah May 25 '11 at 15:01
  • I've revisited my issue and found a few things. 1) UIImage imageNamed: is a memory pig because it caches all of the images. I have replaced with UIImage imageWithContentsOfFile: to reduce the memory used 2) the didReceiveMemoryWarning is forcing my view to unload and as a result is destroying a lot of objects, including those that are visible. I still need to determine how to keep those objects from being unloaded. – Mark Chackerian Jun 14 '11 at 18:21
  • That is Great .... I will try that ... I am also using lots of Images to my Applications. I should try the same thing. Thanks Mark – Darshan Shah Jun 14 '11 at 20:59