I'm using MFMailComposeViewController to send email.
But it crashed when sending large attachments, because of low-memory.
Does 'Mail' allocate memory for attachments?
And how should I do to
>
Dec 3 11:57:36 unknown kernel[0] <Debug>: launchd[1507] Builtin profile: container (sandbox)
Dec 3 11:57:36 unknown kernel[0] <Debug>: launchd[1507] Container: /private/var/mobile/Applications/776D8BB7-805E-46B1-B208-DF2CFE46AB3A [69] (sandbox)
> >
Dec 3 11:57:48 unknown MobileMail[1483] <Warning>: Received memory warning.
Dec 3 11:57:49 unknown com.apple.launchd[1] <Notice>: (UIKitApplication:com.apple.mobilemail[0x26be]) Exited: Killed: 9
Dec 3 11:57:49 unknown com.apple.launchd[1] <Notice>: (UIKitApplication:com.yourcompany.TestApp[0xc7ed]) Exited: Killed: 9
Dec 3 11:57:49 unknown UserEventAgent[12] <Notice>: jetsam: kernel termination snapshot being created
Dec 3 11:57:49 unknown SpringBoard[1186] <Warning>: Application 'TestApp' exited abnormally with signal 9: Killed: 9
>
Dec 3 11:57:50 unknown SpringBoard[1186] <Warning>: Application 'Mail' exited abnormally with signal 9: Killed: 9
Dec 3 11:57:50 unknown SpringBoard[1186] <Warning>: Received memory warning.
Dec 3 11:57:50 unknown ReportCrash[1509] <Error>: Saved crashreport to /Library/Logs/CrashReporter/LowMemory-2012-12-03-115750.plist using uid: 0 gid: 0, synthetic_euid: 0 egid: 0
Dec 3 11:57:50 unknown kernel[0] <Debug>: launchd[1510] Builtin profile: MobileMail (sandbox)
If your attachment data is the contents of a file on disk, the best you can do as the caller is create an NSData object from a mapped file:
NSData * attachmentData = [NSData dataWithContentsOfFile:myPath
options:NSDataReadingMappedIfSafe error:&error];
This transparently keeps the file on disk until parts of it are accessed, and allows the system to be as efficient as it can be.
But beyond that, if you run out of memory on the device, the attachment is too big. It's also fairly likely that the if the device runs out of memory trying to attach an email, the email service probably wouldn't accept the email message anyways it would be so large.
Mail doesn't have a limit, but an ISP would. A realistic limit for most people is probably 10MB, though you may want to keep it more around 5MB and split things across emails...
You can calculate the size of NSData using below code
NSData *pdfData=[NSData dataWithContentsOfFile:strpdfpath];
NSLog(#"PDFData Length is %.02fmb",(float)(int)[pdfData length]/1048576);
Then you can delete the file after successfully attached,
[[NSFileManager defaultManager] removeItemAtPath:[strpdfpath stringByDeletingLastPathComponent] error:&err];
Related
I have a sample App that works fine on the simulator, but crashes on the device. I get the following output on the console from Organizer. It crashes within a short time.
Using instruments, memory leak, I see that the memory usage is about 2-3 mb. Using memory allocations, I see around 8-9mb for memory allocations and nothing in VM tracker.
The console output is given below. Can anyone kindly suggest what to do?
pr 26 11:46:37 unknown SpringBoard[15] <Warning>: Memory level is not normal (2). Delaying auto-relaunch of 'com.apple.mobilemail' for 30 seconds.
Apr 26 11:46:44 unknown SpringBoard[15] <Warning>: No valid 'aps-environment' entitlement string found for application 'SampleApp': (null). Notifications will not be delivered.
Apr 26 11:46:44 unknown SampleApp[14834] <Warning>: unique id: //someID
Apr 26 11:46:45 unknown SampleApp[14834] <Warning>: Failed to get token, error: Error Domain=NSCocoaErrorDomain Code=3000 "no valid 'aps-environment' entitlement string found for application" UserInfo=0x2322ae {NSLocalizedDescription=no valid 'aps-environment' entitlement string found for application}
Apr 26 11:46:46 unknown UserEventAgent[12] <Notice>: jetsam: kernel termination snapshot being created
Apr 26 11:46:46 unknown com.apple.debugserver-64[14833] <Warning>: 1 [39f1/1303]: error: ::read ( 4, 0x2ff389d4, 1024 ) => -1 err = Bad file descriptor (0x00000009)
Apr 26 11:46:46 unknown com.apple.launchd[1] <Notice>: (com.apple.atc) Exited: Killed: 9
Apr 26 11:46:46 unknown com.apple.launchd[1] <Notice>: (UIKitApplication:com.fun.SampleApp.ios[0x2344]) Bug: launchd_core_logic.c:3730 (25147):3
Apr 26 11:46:46 unknown com.apple.launchd[1] <Notice>: (UIKitApplication:com.fun.SampleApp.ios[0x2344]) Assuming job exited: <rdar://problem/5020256>: 10: No child processes
Apr 26 11:46:46 unknown com.apple.launchd[1] <Warning>: (UIKitApplication:com.fun.SampleApp.ios[0x2344]) Job appears to have crashed: Segmentation fault: 11
Apr 26 11:46:46 unknown com.apple.launchd[1] <Notice>: (com.apple.mediaserverd) Exited: Killed: 9
Apr 26 11:46:46 unknown com.apple.launchd[1] <Notice>: (com.apple.ubd) Exited: Killed: 9
Apr 26 11:46:47 unknown kernel[0] <Debug>: launchd[14836] Builtin profile: mediaserverd (sandbox)
Apr 26 11:46:48 unknown lockdownd[21] <Error>: 2ffd4000 _receive_message: walk away - non-SSL 1
Apr 26 11:46:48 unknown com.apple.mobile.lockdown[21] <Notice>: receive secure message timeout!
Apr 26 11:46:48 unknown ReportCrash[14838] <Error>: Saved crashreport to /Library/Logs/CrashReporter/LowMemory-2012-04-26-114648.plist using uid: 0 gid: 0, synthetic_euid: 0 egid: 0
Apr 26 11:46:49 unknown mediaserverd[14836] <Error>: 11:46:49.618590 com.apple.AVConference: /SourceCache/GameKitServices/GameKitServices-344.3/AVConference.subproj/Sources/AVConferenceServer.m:1862: AVConferenceServerStart aborting - device doesn't support conferencing
Apr 26 11:46:49 unknown SpringBoard[15] <Warning>: Application 'SampleApp' exited abnormally with signal 11: Segmentation fault: 11
Apr 26 11:46:52 unknown atc[14835] <Warning>: Error: Connection invalid
Apr 26 11:46:53 unknown wifid[27] <Error>: WiFi:[357158813.1212122]: Client itunesstored is background application
Apr 26 11:47:07 unknown SpringBoard[15] <Warning>: Memory level is not normal (2). Delaying auto-relaunch of 'com.apple.mobilemail' for 30 seconds.
Apr 26 11:47:37 unknown SpringBoard[15] <Warning>: Memory level is not normal (2). Delaying auto-relaunch of 'com.apple.mobilemail' for 30 seconds.
Apr 26 11:48:07 unknown SpringBoard[15] <Warning>: Memory level is not normal (2). Delaying auto-relaunch of 'com.apple.mobilemail' for 30 seconds.
Apr 26 11:48:37 unknown SpringBoard[15] <Warning>: Memory level is not normal (2). Delaying auto-relaunch of 'com.apple.mobilemail' for 30 seconds.
Apr 26 11:48:49 unknown SpringBoard[15] <Notice>: Posting 'com.apple.iokit.hid.displayStatus' notifyState=0
ok, so it seems like everything was fine, I just needed to delete the app from the iPad and reinstall it... pretty weird... !!!
My app has some kind of Zombie problem. (Not an NSZombie problem. Like, a coming-back-from-the-dead problem.)
I first noticed that after a debugging session, when I would go for a run the music on my iPhone would pause every ~7 minutes, and when I'd unlock the device the app name would be flashing red in the status bar as though it had just crashed. Sometimes there would even be phantom sound from the app, like it was still running in the background somehow.
Manually quit the app, continue. Still get the intermittent audio artifacts even though the app no longer appears in my list of running apps.
When I plug back in, this is in the console for each time the app zombified and restarted itself. It looks just like a normal launch of the app! What the? What could be triggering my app to restart itself?
Console:
Apr 26 12:10:01 unknown Breakout[2658] <Warning>: cocos2d: cocos2d v1.1.0-beta2b
Apr 26 12:10:01 unknown Breakout[2658] <Warning>: cocos2d: Using Director Type:CCDirectorDisplayLink
Apr 26 12:10:01 unknown Breakout[2658] <Warning>: cocos2d: OS version: 5.1 (0x05010000)
Apr 26 12:10:01 unknown Breakout[2658] <Warning>: cocos2d: GL_VENDOR: Imagination Technologies
Apr 26 12:10:01 unknown Breakout[2658] <Warning>: cocos2d: GL_RENDERER: PowerVR SGX 535
Apr 26 12:10:01 unknown Breakout[2658] <Warning>: cocos2d: GL_VERSION: OpenGL ES-CM 1.1 IMGSGX535-63.24
Apr 26 12:10:01 unknown Breakout[2658] <Warning>: cocos2d: GL_MAX_TEXTURE_SIZE: 2048
Apr 26 12:10:01 unknown Breakout[2658] <Warning>: cocos2d: GL_MAX_MODELVIEW_STACK_DEPTH: 16
// etc //
Apr 26 12:10:01 unknown kernel[0] <Debug>: launchd[2658] Builtin profile: container (sandbox)
Apr 26 12:10:01 unknown kernel[0] <Debug>: launchd[2658] Container: /private/var/mobile/Applications/FFEB0A26-06D1-4C46-8AE5-C60582D09A1D [69] (sandbox)
Apr 26 12:10:01 unknown Breakout[2658] <Warning>: Audio session details
Apr 26 12:10:01 unknown Breakout[2658] <Warning>: Audio Input Available? YES
Apr 26 12:10:01 unknown mediaserverd[32] <Warning>: 12:10:01.641 <SystemSoundServer> WARNING translating HAL error: 561214578
Apr 26 12:10:01 unknown Breakout[2658] <Warning>: Max Possible Inputs 15151420
Apr 26 12:10:01 unknown Breakout[2658] <Warning>: Outputs 2
Apr 26 12:10:01 unknown Breakout[2658] <Warning>: Device sample rate 44100.000000
Apr 26 12:10:01 unknown Breakout[2658] <Warning>: Hardware buffer size 0.023220
// etc //
Apr 26 12:10:33 unknown SpringBoard[52] <Notice>: Posting 'com.apple.iokit.hid.displayStatus' notifyState=1
Apr 26 12:10:33 unknown UserEventAgent[12] <Warning>: DEBUG: Changing screen blanked state: 0
Apr 26 12:10:33 unknown SpringBoard[52] <Notice>: MultitouchHID: detection mode: 255->0 (deferring until bootloaded)
Apr 26 12:10:33 unknown SpringBoard[52] <Notice>: MultitouchHID: device bootloaded
Apr 26 12:10:33 unknown SpringBoard[52] <Notice>: MultitouchHID: detection mode: 0->0
Apr 26 12:10:34 unknown kernel[0] <Debug>: set_crc_notification_state 0
Apr 26 12:10:34 unknown ReportCrash[2659] <Notice>: Formulating crash report for process Breakout[2658]
>
Apr 26 12:10:34 unknown SpringBoard[52] <Warning>: pid_suspend failed for [2658]: Unknown error: -1, Unknown error: -1
Apr 26 12:10:34 unknown SpringBoard[52] <Warning>: Could not set priority of [2658] to 4096, priority: No such process
Apr 26 12:10:34 unknown com.apple.launchd[1] <Warning>: (UIKitApplication:com.charliewilliams.Breakout[0xd5ad]) Job appears to have crashed: Trace/BPT trap: 5
Apr 26 12:10:34 unknown SpringBoard[52] <Warning>: Application 'Breakout' exited abnormally with signal 5: Trace/BPT trap: 5
Apr 26 12:10:35 unknown ReportCrash[2659] <Error>: libMobileGestalt computeUniqueDeviceID: total time for bb to return imei: 0
Apr 26 12:10:35 unknown ReportCrash[2659] <Notice>: Saved crashreport to /var/mobile/Library/Logs/CrashReporter/Breakout_2012-04-26-121033_Tortuga-Gigante.plist using uid: 0 gid: 0, synthetic_euid: 501 egid: 0
Explanation of the solution: It turned out to be simple - 1. I was shutting down my audio session in dealloc but not in applicationDidEnterBackground. And since I'm using kaudiosessioncategory_playandrecord that seems to tell iOS to restart the app if it crashes in the background.
Now, why is it crashing in the background? ...well, that's my next task.
The app may have a background voip flag set. If it does, the OS will restart the app if it exits abnormally (or when the device restarts).
what audio framework are you using? the iPod app, GarageBand and other audio apps present red flashing in the title bar when audio processing continues after exiting the app. This wouldn't happen with Cocos Denshion I don't think, so you must be using an Apple framework for your audio? The answer likely lies with how it is configured. Apple gives some of its own audio frameworks permission to keep running when in the background so you can have customized music playing, like apps for radio stations, etc.
We will probably need code snippets also as the logs don't tell us what code is executed
I have developed a sample iPad application in which I open the one file of type ppt in UIWebView. When I run this application on iPad having O.S version 5.0(iPad2) & 4.3.1(iPad1) the application gets crash with following error(Memory Warning):
Apr 11 11:01:23 unknown WebViewTest[345] <Warning>: Received memory warning.
Apr 11 11:01:24 unknown UserEventAgent[12] <Notice>: jetsam: kernel termination snapshot being created
Apr 11 11:01:24 unknown com.apple.launchd[1] <Notice>: (UIKitApplication:com.apple.Preferences[0x3072]) Exited: Killed: 9
Apr 11 11:01:24 unknown com.apple.launchd[1] <Notice>: (UIKitApplication:com.extentia.DMG[0x6ba7]) Exited: Killed: 9
Apr 11 11:01:24 unknown SpringBoard[15] <Warning>: Application 'Settings' exited abnormally with signal 9: Killed: 9
Apr 11 11:01:24 unknown SpringBoard[15] <Warning>: Application 'DMG' exited abnormally with signal 9: Killed: 9
Apr 11 11:01:25 unknown ReportCrash[347] <Error>: Saved crashreport to /Library/Logs/CrashReporter/LowMemory-2012-04-11-110125.plist using uid: 0 gid: 0, synthetic_euid: 0 egid: 0
Apr 11 11:01:25 unknown WebViewTest[345] <Warning>: Received memory warning.
Apr 11 11:01:26 unknown SpringBoard[15] <Warning>: Received memory warning.
Apr 11 11:01:26 unknown com.apple.launchd[1] <Notice>: (UIKitApplication:com.extentia.WebViewTest[0x99f4]) Exited: Killed: 9
Apr 11 11:01:26 unknown UserEventAgent[12] <Notice>: jetsam: kernel termination snapshot being created
Apr 11 11:01:26 unknown SpringBoard[15] <Warning>: Application 'WebViewTest' exited abnormally with signal 9: Killed: 9
Apr 11 11:01:35 unknown ReportCrash[348] <Error>: Saved crashreport to /Library/Logs/CrashReporter/LowMemory-2012-04-11-110135.plist using uid: 0 gid: 0, synthetic_euid: 0 egid: 0
But when I run same application on iPad having O.S version 4.3.3(iPad2) it runs perfectly. What is the reason behind this strange behavior & any solution to solve this. Thanks in advance.
your app is crashing because it ran out of memory.
Try using PDF format or PPS (power point slide show) format. That may take some lesser space.
I have developed a simple app that calculates the risk of developing type 2 diabetes. The app runs fine from xcode on my iPhone 3Gs. I archived the app in a .ipa file and I have uploaded the app to my testflightapp.com account. I have installed the app on my iPhone with the standard testflightapp.com procedure: clicking the install link in the email from testflightapp.com.
When I run the app, I see the launch image for a few seconds and then it goes away. The console of my iPhone in xcode displays what is going wrong, but I do not know what this means:
Jan 8 20:00:42 unknown com.apple.launchd[1] <Warning>: (UIKitApplication:com.reinvdo.diabete[0xa6a]) Conflict with job: UIKitApplication:com.reinvdo.diabete[0x291b] over Mach service: com.reinvdo.diabete
Jan 8 20:00:42 unknown com.apple.launchd[1] <Warning>: (UIKitApplication:com.reinvdo.diabete[0xa6a]) Conflict with job: UIKitApplication:com.reinvdo.diabete[0x291b] over Mach service: com.reinvdo.diabete.UIKit.migserver
Jan 8 20:00:42 unknown kernel[0] <Debug>: launchd[4255] Builtin profile: container (sandbox)
Jan 8 20:00:42 unknown kernel[0] <Debug>: launchd[4255] Container: /private/var/mobile/Applications/64A83260-5918-4109-A861-A3399D825654 [69] (sandbox)
Jan 8 20:00:42 unknown com.apple.launchd[1] <Warning>: (UIKitApplication:com.reinvdo.diabete[0x291b]) The following job tried to hijack the service "com.reinvdo.diabete" from this job: UIKitApplication:com.reinvdo.diabete[0xa6a]
Jan 8 20:00:42 unknown UIKitApplication:com.reinvdo.diabete[0xa6a][4255] <Notice>: Couldn't register com.reinvdo.diabete with the bootstrap server. Error: unknown error code.
Jan 8 20:00:42 unknown UIKitApplication:com.reinvdo.diabete[0xa6a][4255] <Notice>: This generally means that another instance of this process was already running or is hung in the debugger.
Jan 8 20:00:43 unknown ReportCrash[4256] <Notice>: Formulating crash report for process diabete[4255]
Jan 8 20:00:43 unknown com.apple.launchd[1] <Warning>: (UIKitApplication:com.reinvdo.diabete[0xa6a]) Job appears to have crashed: Abort trap: 6
Jan 8 20:00:43 unknown SpringBoard[15] <Warning>: Application 'diabete' exited abnormally with signal 6: Abort trap: 6
Jan 8 20:00:43 unknown ReportCrash[4256] <Error>: Saved crashreport to /var/mobile/Library/Logs/CrashReporter/diabete_2012-01-08-200042_reins-iPhone.plist using uid: 0 gid: 0, synthetic_euid: 501 egid: 0
Can anybody shine a light on this error?
On the iPhone, a process of a previous run of the application was still active. To fix the issue, all that is necessary is a reboot.
I'm doing a app like photo browser just like the "Photo" on iTOuch. And I use a third-party lib : https://github.com/kirbyt/KTPhotoBrowser
When I scroll the photos several times, the app crashes.
The log shows that it has receive memory warning.
Then I use instrument to check the memory (I choose Memory-Allocation).
I track the Live Bytes and Overall Bytes for "All Allocations".
However, the Live Bytes is never more than 5 MB, and the Overall Bytes is beyond 100 MB .
When the app carshes, the Live Bytes is 3.97MB and the Overall is 125.48MB.
I think Live Bytes is the memory currently used, and it seems it costs a little.
Why the app still crashes?
Xcode 4.2 4D199,Lion 10.7.2(11c74), iTouch ios5.0.1 beta2.
Below is the screenshot, and the instrument configuration is the default.
Any idea?
the crash log is like:
Nov 8 16:54:42 unknown SpringBoard[15] : Received memory warning.
Nov 8 16:54:43 unknown com.apple.launchd[1] : (UIKitApplication:com.apple.mobilephone[0xcb31]) Exited: Killed: 9
Nov 8 16:54:43 unknown com.apple.launchd[1] : (UIKitApplication:com.freebit.minimumcloud.ios[0xf787]) Exited: Killed: 9
Nov 8 16:54:43 unknown UserEventAgent[12] : jetsam: kernel termination snapshot being created
Nov 8 16:54:43 unknown SpringBoard[15] : Application 'Min.Cloud' exited abnormally with signal 9: Killed: 9
Nov 8 16:54:44 unknown SpringBoard[15] : Application 'FaceTime' exited abnormally with signal 9: Killed: 9
Nov 8 16:54:45 unknown kernel[0] : launchd[481] Builtin profile: container (sandbox)
Nov 8 16:54:45 unknown kernel[0] : launchd[481] Container: /private/var/mobile/Applications/301E2A00-F1B6-4E88-ACF4-8EBEFB92B9DA [69] (sandbox)
Nov 8 16:54:45 unknown librariand[459] : client connection is invalid: Connection invalid
Nov 8 16:54:45 unknown ReportCrash[480] : Saved crashreport to /Library/Logs/CrashReporter/LowMemory-2011-11-08-165445.plist using uid: 0 gid: 0, synthetic_euid: 0 egid: 0
Nov 8 16:54:49 unknown sandboxd[483] : MinimumCloud(481) deny file-write-data /private/var/mobile/Library/Mobile Documents/*********
Nov 8 16:54:50 unknown MinimumCloud[481] : file://localhost/private/var/mobile/Library/Mobile%20Documents/*******/Documents/
Nov 8 16:54:50 unknown sandboxd[483] : MinimumCloud(481) deny file-write-create /file:
Nov 8 16:54:50 unknown MinimumCloud[481] : ubiquityContainerURL=/private/var/mobile/Library/Mobile Documents/******/Documents
Nov 8 16:54:50 unknown sandboxd[483] : MinimumCloud(481) deny file-write-create /file:
Nov 8 16:54:50 unknown MinimumCloud[481] : mystorageSymLink=/var/mobile/Applications/301E2A00-F1B6-4E88-ACF4-8EBEFB92B9DA/Library/htdocs/MyStorage
Nov 8 16:54:51 unknown wifid[27] : WiFi:[342435291.518957]: Disable WoW requested by "spd"
It is my own fault!
when I use NSURLConnection to detect the MIME-TYPE of the file, the memory of the connection is never released and it becomes larger and larger(As I detect the type of more than 100 files).
I reconstruct the code.