Author Topic: GLBasic V11 on iPod Touch 4th Gen. Memory Warnings!  (Read 1889 times)

Offline aroldo

  • Mr. Polyvector
  • ***
  • Posts: 143
    • View Profile
    • APD Consulting, Inc.
Gernot,

As I am getting ready to submit my game to the Apple App Store I am testing my game on different hardwares.
This game is running well on the iPad Min, iPhone 4S running with iOS 6.1.
When I stat the app on the iPod 4th Generation, running iOS 6.1, I get a memory warnings and the application quits.

Here are the memory warnings errors:

2013-02-15 19:13:34.073 BrickBuster[236:907] Received memory warning.
-applicationDidReceiveMemoryWarning - free mem=4032 kB
2013-02-15 19:13:36.091 BrickBuster[236:907] Received memory warning.
-applicationDidReceiveMemoryWarning - free mem=2024 kB
2013-02-15 19:13:37.803 BrickBuster[236:907] Received memory warning.
-applicationDidReceiveMemoryWarning - free mem=4836 kB

Here is the entire Xcode error log

init with frame.
App wants to support retina...
Retina scaleing available: self.contentScaleFactor = 2.000000
desktop backing: 640 x 960
mainScreen: 640x960
glb_notify_screen_size 640x960
slaunch ok
-applicationDidBecomeActive    -> unpause
2013-02-15 19:13:27.501 BrickBuster[236:907] Application windows are expected to have a root view controller at the end of application launch
timer
rbow
rbow init
Rbow::SetScreen( 1536,2048)
get accurate timer - 1st call
flip - 1st call
BGRA ext supported
Texture size limit: 2048
init fbo
2D VP
OGRB init [OK]
Cptn
Network
Input
Window mode
Create DXin
reptr
getexe
cd
exepath=curdir= /var/mobile/Applications/F27E56F4-E05D-42C5-AA81-DF4B705A11B9/BrickBuster.app
shoeboxing...
init gettimer
clear screen
flip
mk2D
finding font...
AudioStreamBasicDescription:  2 ch,  44100 Hz, 'lpcm' (0x00000029) 32-bit little-endian float, deinterleaved
Init Finalized
loadeffect - i: 0 eff: 2400
loadeffect - i: 1 eff: 2402
loadeffect - i: 2 eff: 2404
loadeffect - i: 3 eff: 2406
loadeffect - i: 0 eff: 2408
loadeffect - i: 0 eff: 2410
loadeffect - i: 0 eff: 2412
loadeffect - i: 0 eff: 2414
loadeffect - i: 0 eff: 2416
loadeffect - i: 0 eff: 2418
loadeffect - i: 0 eff: 2420
loadeffect - i: 0 eff: 2422
error:
error:
error:
error:
2013-02-15 19:13:34.073 BrickBuster[236:907] Received memory warning.
-applicationDidReceiveMemoryWarning - free mem=4032 kB
2013-02-15 19:13:36.091 BrickBuster[236:907] Received memory warning.
-applicationDidReceiveMemoryWarning - free mem=2024 kB
2013-02-15 19:13:37.803 BrickBuster[236:907] Received memory warning.
-applicationDidReceiveMemoryWarning - free mem=4836 kB
[a http://apd-games.com/][img http://apd-games.com/images/APDGames135.png][/a]
MacBook Pro OS X El Capitan
XCode Version 7
iPhone 6 running  iOS 9
iPad Mini running  iOS 7.1
Galaxy S5
Dell Latitude Windows 8 Enterprise
Palm Pre, Palm Pre2

Offline spacefractal

  • Community Developer
  • Prof. Inline
  • ******
  • Posts: 3602
    • View Profile
    • Space Fractal
This device have only 256mb ram, so your app uses too much memory to fit.

Howover I do wonder this line:
Rbow::SetScreen( 1536,2048)

Its should not try to set that buffer to this size, which take a lots of memory (if not its just failed trying that?)
« Last Edit: 2013-Feb-16 by spacefractal »
Greedy Mouse - Karma Miwa - Spot Race - CatchOut - Android Extras - is on a vacation trip, home before end of few days in jan.

Offline aroldo

  • Mr. Polyvector
  • ***
  • Posts: 143
    • View Profile
    • APD Consulting, Inc.
spacefractal,

It is interesting that it does not load on iPod 3 generation because this game loads an runs on the Palm Pre 2 and HP Touchpad!
All the images in my game have the resolution to fit the 2048 x 1536 ( iPad 3 Retina Display), this is because the same application can run on any screen format up to the iPad 3.
Based on the device screen size I scale the image down to the appropriate format, that works really good because I have the best image quality in any screen format.

Is there a way to scale the images before I load them into device memory?
[a http://apd-games.com/][img http://apd-games.com/images/APDGames135.png][/a]
MacBook Pro OS X El Capitan
XCode Version 7
iPhone 6 running  iOS 9
iPad Mini running  iOS 7.1
Galaxy S5
Dell Latitude Windows 8 Enterprise
Palm Pre, Palm Pre2

Offline spacefractal

  • Community Developer
  • Prof. Inline
  • ******
  • Posts: 3602
    • View Profile
    • Space Fractal
That because those devices have a least 512mb ram, iPods only have 256mb ram (except generation 5 have 512mb ram). That means you only have about around 70mb ram to work with. So scaling down from iPad 3 have taken too much memory, due offbuffer take a lots of memory.

Rapids Rider did also suffer same issue, so they forced to remove the screen wipes to safe memory and then works on iPad 1, which also only have 256mb ram.

So you property need to rescaling down by factor two and load those textures directly. In my own game, Genius Greedy Mouse, uses 3 sizes of textures (except few graphics), which was to save ram. Howover It's take a lots of file size, but better that than use more ram.

So in the end, you simply uses too much memory, so it's crash because you can't fit and resize all graphics used.
« Last Edit: 2013-Feb-16 by spacefractal »
Greedy Mouse - Karma Miwa - Spot Race - CatchOut - Android Extras - is on a vacation trip, home before end of few days in jan.

Offline hardyx

  • Community Developer
  • Dr. Type
  • ******
  • Posts: 490
    • View Profile
All the images in my game have the resolution to fit the 2048 x 1536 ( iPad 3 Retina Display), this is because the same application can run on any screen format up to the iPad 3.
Based on the device screen size I scale the image down to the appropriate format, that works really good because I have the best image quality in any screen format.

Is there a way to scale the images before I load them into device memory?
Maybe the iOS 6.1 uses more memory and not works good in earlier devices. You can use two set of images, one for iPad3 and one pre-rescaled for iPhone/iPad 2 and older devices. Rescaling at runtime loads the cpu too, then your game will work faster for older devices. You can make this at beggining of the app, drawing the images rescaled in a memory screen and unload the original images, but is better pre-rescaling in files to save work for the device.
« Last Edit: 2013-Feb-17 by hardyx »

Offline aroldo

  • Mr. Polyvector
  • ***
  • Posts: 143
    • View Profile
    • APD Consulting, Inc.
hardyx, do you have an example?

Is it possible to load the image than re size it and save it back to the device memory?
I looked at the GLB commands but could not find a command to save the re sized image back to the file.
[a http://apd-games.com/][img http://apd-games.com/images/APDGames135.png][/a]
MacBook Pro OS X El Capitan
XCode Version 7
iPhone 6 running  iOS 9
iPad Mini running  iOS 7.1
Galaxy S5
Dell Latitude Windows 8 Enterprise
Palm Pre, Palm Pre2

Offline spacefractal

  • Community Developer
  • Prof. Inline
  • ******
  • Posts: 3602
    • View Profile
    • Space Fractal
he wrote its best to prescaling directly to files as the best way.

Glbasic cant reduce automatic, but you can use SPRITE2MEM command as well CREATESCREEN to reduce its by you self, but its also take up to around 20MB ram doing for bigger images, which means you will run out of memory under converting sooner or later. so is not a good way to due for 256mb devices. You should not rescaling on the fly on a least on the biggest images as well using Retina 3 offscreen buffer size (which require a lots of uneccery memory).

Here is a example what I did in Greedy Mouse for most images:
mouse_effects_1.png (256x512) <- Smaller resoulutions, like 480x320.
mouse_effects_2.png (512x1024) <- iPhone Retina.
mouse_effects_4.png (1024x2048)  <-  iPad Retina.

Those files is 2.26mb total (192kb,542kb,1.54mb).
Greedy Mouse - Karma Miwa - Spot Race - CatchOut - Android Extras - is on a vacation trip, home before end of few days in jan.

Offline hardyx

  • Community Developer
  • Dr. Type
  • ******
  • Posts: 490
    • View Profile
he wrote its best to prescaling directly to files as the best way.
Right, rescaling to files depending the device model is the best option for save memory.