|
|
#1 |
|
Game using large amounts of memory
I'm developing an iOS game that has shooting and reload animations for weapons. Per gun, the total of the images that make up the animation is only about 10MB, yet when they load on the device (retina iPad) the app increases in memory use by about 400MB. Why is this?
When the shooting view loads, it loads the images into two arrays (fire and reload), and plays the animation over in 0.1 seconds before it loads so that there is no delay when shooting or reloading. There is little else in the view that would be using large amounts of memory. What would you recommend I do to decrease the amount of memory the game is using?
__________________
Macbook Air 13", 1.7GHz i5, 4GB RAM, 256GB SSD Black 3rd generation iPad, Wi-Fi + 4G 32GB Black iPhone 5, 16GB |
|
|
|
0
|
|
|
#2 |
|
How are you loading the images?
__________________
|
|
|
|
0
|
|
|
#3 |
|
Like this: ('rev' is the UIImageView the animation plays in, gunanimload is the array)
Code:
- (void)viewDidLoad
{
[super viewDidLoad];
myQueue = dispatch_queue_create("com.dubzem.shooting", NULL);
dispatch_async(myQueue, ^{
gunanimload = [NSArray arrayWithObjects:
[UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"rev0001" ofType:@"png"]],
[UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"rev0002" ofType:@"png"]],
(etc x 30) nil];
rev.animationImages = gunanimload;
rev.animationDuration = 0.10;
rev.animationRepeatCount = 1;
[rev startAnimating];});
}
Code:
type.animationImages = gunanimload;
type.animationDuration = 0.5;
type.animationRepeatCount = 1;
[type startAnimating];
__________________
Macbook Air 13", 1.7GHz i5, 4GB RAM, 256GB SSD Black 3rd generation iPad, Wi-Fi + 4G 32GB Black iPhone 5, 16GB |
|
|
|
0
|
|
|
#4 |
|
Is this an efficient way to load and play a PNG animation? I'm wondering why it's using so much memory even though the images are small in size.
__________________
Macbook Air 13", 1.7GHz i5, 4GB RAM, 256GB SSD Black 3rd generation iPad, Wi-Fi + 4G 32GB Black iPhone 5, 16GB |
|
|
|
0
|
|
|
#5 |
|
I warmly recommend you use Instruments. If you really have more than ten times greater memory usage than what you'd expected, you should stop guessing and start with the Instruments.
There you'll see the objects that occupy a lot of memory. 400MB on iOS device is an incredible amount of memory. You'll see malloc blocks too, and guessing where they come from may take a bit more time but their size should point you in the right direction.
__________________
GlideShow - Slideshows with images from Reddit, Facebook, Flickr, Dropbox, SkyDrive & Google.
|
|
|
|
0
|
|
|
#6 |
|
The amount of memory used by an image is wxhx4. It's not the same as the size of the image on disk.
|
|
|
|
0
|
![]() |
|
| Tags |
| ios, ipad, iphone, objective-c, xcode |
«
Previous Thread
|
Next Thread
»
| Thread Tools | Search this Thread |
| Display Modes | |
|
|
All times are GMT -5. The time now is 02:41 AM.






I support the 

Linear Mode
