Tables and memory usage

CasualEvolutionCasualEvolution Member, PRO Posts: 543
Hi, is there any way to calculate the approximate size in bytes of a table?.
I mean, if I create a table of 50 columns x 500 rows, I have a total of 25,000 cells, I wonder how much ram will consume this table later.
I guess depends on the type of cell that is, if it is boolean, integer, real, etc.
We could give an approximate weight of "a cell" of each type? for example: a boolean 1 byte, a integer 10-byte, a real 50 bytes.
I have been optimizing the size of a table, however perhaps it is a resource "cheap" and not worth optimizing and complicate the code.
Maybe someone from the development team, @CodeWizard?

Thank you very much

Comments

  • The_Gamesalad_GuruThe_Gamesalad_Guru Member Posts: 9,922
    Tables aren't memory hogs as they are dormant unill referenced.
  • CasualEvolutionCasualEvolution Member, PRO Posts: 543
    ok, I understand, I thought that running an application, it is fully loaded in ram. So the question I have is how much it contributes to the total size of the application? thanks
  • natzuurnatzuur Member Posts: 304
    Tables have a very small file size in general, but changes with the amount of data stored.
  • CasualEvolutionCasualEvolution Member, PRO Posts: 543
    edited June 2013
    Exactly, what is the size of a table in memory will depend on how many cells have and what type. If I have a table of 900x900, then there will be 810,000 cells, assuming that I keep are real numbers and if everyone takes 5 bytes, then the table will have a size of 4 megabytes, which depending on the type of application you're doing is a issue to consider.
    I have no idea how much weight each cell in the format, but perhaps @CodeWizard, @BobCoddSalad or @SaladStraightShooter can give us an idea.
    Thank you.
  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    Are you actually creating an app with 900 rows and 900 columns or is this hypothetical? Your example of 25,000 cells at 5 bytes would take up 125k of space if I'm not mistaken. Seems like a trivial amount, but it's an interesting question.

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • CasualEvolutionCasualEvolution Member, PRO Posts: 543
    Hello @tatiang, is hypothetical, so are the 5 bytes per cell, and if you are 30? as we do not know, I wonder how long it will be the size of a table when you create it, I think it is useful, especially when you want to make intensive use of tables.
    Thank you.
  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    I think it could be useful information. I just have never considered it because my most data-intensive app only uses about 15,000 cells.

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • grimtoothgrimtooth Member Posts: 69
    Useful or not I do not know, but my Hex Editor displays 3 memory types in iOS and they are 1,2,and 4 bytes. I assume that Boolean =1 byte since that memory size appears to exist in ios, integer=4 bytes, real (float) will either be 4 or 8 bytes. 8 bytes will store 5e-324 to 1.8e308 so I don't foresee any larger memory allocation being used by GS very often so there will be no "50 byte" cells.

    A 512x512 table of 4 byte data will be 1MB
    So your 50x500 table is probably approx 100KB (smaller than your background ill bet)


    In addition I found this:


    Blocks from separate memory allocations are not allocated contiguously (separate calls to alloc, malloc, new, etc.). Otherwise they are allocated contiguously(from the same call to malloc, ex. new float[30]). According to Apple your app risks being shut down for memory usage when you use more than 20mb of ram. In practice however, you can get to about...

    260 MB of ram on iPad 2 (Thanks RobCroll)
    170-180MB of ram on devices with 512 Mb of ram total (iPhone 4, iPod touch 4g)
    40-80MB of ram on devices that have 256 MB of ram (iPad, iPhone 3gs, iPod touch 3g)
    25 MB on device with only 128MB of ram (IPhone 3g, iPhone 2g, iPod touch 1g-2g)
    If you really "need" that much ram for a mobile application, you should really save the data to a temp file and do your processing on that. An easy way to do that is by using memory mapped files.

    share|improve this answer
    edited Jun 2 at 8:16

    answered May 18 '11 at 12:07

    Skyler Saleh
    2,399724
  • CasualEvolutionCasualEvolution Member, PRO Posts: 543
    Hi @grimtooth thanks, this was the information I wanted. Thank you very much :)
Sign In or Register to comment.