I have an iPhone Windows-based Monotouch application that appears to use more memory to run on an iPad versus an iPhone and iPhone simulator.
After monitoring memory allocations in Instruments, I noticed that there are two additional instances that are only instantiated on the iPad (see screenshot below.) When following the same steps for iPhone and simulator, they are not present. They are some big hitters totaling around 4MB. The responsible library for these two instances are "CoreGraphics." I was able to track down when they get instantiated and I'm left in the dark because it's right after ViewDidLoad is done. Between a breakpoint on the last line in ViewDidLoad and when everything shows up on the screen, bam! 4 additional mb being used. The XIB is empty because I manually add everything in code so I can't figure out what would be going on after ViewDidLoad that would make these.
I'd like to get to the bottom of this because the app is already pushing memory limits. It's the difference between working fine on the iPhone and crashing very quickly on the iPad (memory related.) So, with out going into any details about the application, what would cause an iPad to instantiate these additi开发者_StackOverflow中文版onal CoreGraphics related monsters versus not on an iPhone or simulator?
It turned out to be a rookie mistake on my part.
All my images were retina (double sized) but were named like normal images, myimage.png. I guess the iPad I have does not support retina graphics and was probably overwhelmed trying to re-size all the retina graphics to normal size.
I whipped up a script to rename all my graphics to myimage@2x.png and went back and cut all my graphics to normal size with normal names, myimage.png. After that, the iPad was a happy camper and the large allocs were no where to be found!
精彩评论