Tables and memory usage
CasualEvolution
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
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
Guru Video Channel | Lost Oasis Games | FRYING BACON STUDIOS
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.
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
Thank you.
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
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