Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / Saving lots of data

Author
Message
The Zoq2
14
Years of Service
User Offline
Joined: 4th Nov 2009
Location: Linköping, Sweden
Posted: 21st Oct 2012 20:56 Edited at: 21st Oct 2012 21:25
Hi, I started working on saving for my game that im working on. Basicaly I have a 10000 "tile" island, which have 6 variables each that need to be saved in order to load the same island propperly. And as you may suspect (but it didn't occur to me until now ) Saving 60k floats takes a bit longer than what's acceptable. Right now it takes 170 seconds on my PC, about 200 on my phone and 300 on my tablet. And I wouldn't want to wait 300 secs to save my progress .

This means that I have to figure out a better way of saving the world. I could save while playing, but that would probably have some impact on performance, whic is already pretty bad on my tablet. And im guessing that if the game would crash or get shut down, the saves could become corrupt. Another problem is that I would need to edit the savefile which I don't even know is is possible.

A third option would be to divide the area into chunks, with 10x10 tiles eahc, and then the game would remember what chunks have changed and when the user saves, it would only save the changed chunks.

Do you have any other ideas?

This is the code, whic is realy slow, but it shows you how much data I need to save.


One thing to note, is that the whole world is made out of 3 blocks (with stuff on them) so perhaps I can save the tiles as areas of the same things instead of separate tiles.

Edit Ehh I found the problem. I put a sync command in there to print the progress. But I didn't think about the fact that sync actually syncs and caps the game at 60 FPS. So that decreased the time to save to 1 second instead of 170.

Edit 2And just as I fixed the problem, another arises. Now when I try to save on my 2 android devices, the app crashes, and my tablet which has a live walpaper, removes it. The phone just reloads all icons. Could it be a out of ram error...
ICERGB
21
Years of Service
User Offline
Joined: 8th Nov 2002
Location: Canada
Posted: 23rd Oct 2012 17:32
I was having trouble with open to read command not working properly on my android devices as well.
Does it load the database at all? and/or did you get it fixed?
kamac
13
Years of Service
User Offline
Joined: 30th Nov 2010
Location: Poland
Posted: 23rd Oct 2012 18:17 Edited at: 23rd Oct 2012 18:17
Quote: "Could it be a out of ram error..."


60.000 integers, saying that one could take 16 bytes, it's 960000 bytes.... Divide that by 1024 = 937.5 kilobytes, which isn't even 1mb of RAM.

Or I counted it wrong.

Follow me on twitter! @MotionStruct
Motion Struct blog
The Zoq2
14
Years of Service
User Offline
Joined: 4th Nov 2009
Location: Linköping, Sweden
Posted: 23rd Oct 2012 18:26 Edited at: 23rd Oct 2012 18:26
I managed to fix it, my theory is that there was a print command in the for loop. Which means it printed 10000 lines before finishing with the loading, and that ate all the ram. But im not sure if that was the problem

Edit, you are correct, the files take up 200kb or so...
kamac
13
Years of Service
User Offline
Joined: 30th Nov 2010
Location: Poland
Posted: 23rd Oct 2012 19:23
Quote: "Edit, you are correct, the files take up 200kb or so..."


I guess that integer is 8 bytes then on android / w/e system you use.

Follow me on twitter! @MotionStruct
Motion Struct blog
Cliff Mellangard 3DEGS
Developer
18
Years of Service
User Offline
Joined: 20th Feb 2006
Location: Sweden
Posted: 23rd Oct 2012 19:24 Edited at: 23rd Oct 2012 19:25
remove the sync inside the for to loop so will it get alot faster!
You are using sync Xmax*YMax times in your routine and thats not healthy.

Edited....
noticed your edit.
Are you really sure its faster with it inside the loop?

Android 2.3 , ZTE Skate , 480x800 , 800 mhz , Samsung Galaxy Y , 240x320 , 832 mhz , Sony ericson arc 480x854 , 1 ghz
Android 4.0 , Dmtech 3g 9738B , 1024x768 , 9.7 inches , 1.2 ghz
kamac
13
Years of Service
User Offline
Joined: 30th Nov 2010
Location: Poland
Posted: 23rd Oct 2012 19:26
Cliff,

Quote: "Edit Ehh I found the problem. I put a sync command in there to print the progress. But I didn't think about the fact that sync actually syncs and caps the game at 60 FPS. So that decreased the time to save to 1 second instead of 170."


Read carefuly

Follow me on twitter! @MotionStruct
Motion Struct blog
Cliff Mellangard 3DEGS
Developer
18
Years of Service
User Offline
Joined: 20th Feb 2006
Location: Sweden
Posted: 23rd Oct 2012 19:27
Quote: "Read carefuly "

Dont want to

Android 2.3 , ZTE Skate , 480x800 , 800 mhz , Samsung Galaxy Y , 240x320 , 832 mhz , Sony ericson arc 480x854 , 1 ghz
Android 4.0 , Dmtech 3g 9738B , 1024x768 , 9.7 inches , 1.2 ghz
The Zoq2
14
Years of Service
User Offline
Joined: 4th Nov 2009
Location: Linköping, Sweden
Posted: 23rd Oct 2012 19:42
Quote: "Are you really sure its faster with it inside the loop?"


Sure what is faster within the loop?
Cliff Mellangard 3DEGS
Developer
18
Years of Service
User Offline
Joined: 20th Feb 2006
Location: Sweden
Posted: 24th Oct 2012 00:02
Quote: "Sure what is faster within the loop? "

With the sync inside the 2 for to loops.

You sync the screen loop 1*loop 2 and that a whole lot of syncing going on.

Android 2.3 , ZTE Skate , 480x800 , 800 mhz , Samsung Galaxy Y , 240x320 , 832 mhz , Sony ericson arc 480x854 , 1 ghz
Android 4.0 , Dmtech 3g 9738B , 1024x768 , 9.7 inches , 1.2 ghz
The Zoq2
14
Years of Service
User Offline
Joined: 4th Nov 2009
Location: Linköping, Sweden
Posted: 24th Oct 2012 00:33
Oh yes, removing it cut down the time to save 1000 times

Login to post a reply

Server time is: 2024-04-28 07:04:01
Your offset time is: 2024-04-28 07:04:01