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.

DarkBASIC Professional Discussion / Byte arrays are not as RAM friendly as I suspected

Author
Message
Chris Tate
DBPro Master
17
Years of Service
User Offline
Joined: 29th Aug 2008
Location: London, England
Posted: 16th Jun 2013 20:15
I have a situation where lots of state data needs to be made available without consuming too much RAM. I would have used integers if speed was the priority; but due to constantly converting arrays to memblocks, I have stuck with bytes, hoping to also save lots of RAM, but the following test shows that there is potentially only a 30% difference.



Sergey K
22
Years of Service
User Offline
Joined: 4th Jan 2004
Location:
Posted: 16th Jun 2013 20:20 Edited at: 16th Jun 2013 20:22
how about using HDD instead?
use saving to file for your data

edit: and how about using Dynamic arrays?
just create another array entry if needed using Insert array at Bottom

Stream SnifferTools/Plugins/Models/Games and more!
Chris Tate
DBPro Master
17
Years of Service
User Offline
Joined: 29th Aug 2008
Location: London, England
Posted: 16th Jun 2013 22:06
Yeah I already use dynamic arrays; I just thought bytes arrays where 4 times smaller than integer arrays, afterall an integer uses 4 bytes.

TheComet
18
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 16th Jun 2013 22:54
Nope, look at the disassembly of a DBP executable if you want to see absolute horror, and why a byte uses 4 bytes of RAM.

TheComet


Yesterday is History, Tomorrow is a Mystery, but Today is a Gift. That is why it is called "present".
Chris Tate
DBPro Master
17
Years of Service
User Offline
Joined: 29th Aug 2008
Location: London, England
Posted: 17th Jun 2013 04:16 Edited at: 17th Jun 2013 04:17
Lol; so a byte is not a byte; and a boolean is not a boolean. Just clamped integers. Well, at least in memblock form there is a decent difference.

TheComet
18
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 17th Jun 2013 09:12
Here's another cool piece of code.



For those who won't run it, the output is 255.

TheComet


Yesterday is History, Tomorrow is a Mystery, but Today is a Gift. That is why it is called "present".
Burning Feet Man
18
Years of Service
User Offline
Joined: 4th Jan 2008
Location: Sydney, Australia
Posted: 17th Jun 2013 11:39
Yah, I've been wrapping my Boolean to 1 for sometime now. If anything, I still identify my globals & locals as a Boolean to clarify the variable/arrays purpose.

Help build an online DarkBASIC Professional help archive.
DarkBasic Help Wikia
GIDustin
18
Years of Service
User Offline
Joined: 30th May 2008
Location:
Posted: 18th Jun 2013 02:36
I think this is something that should be addressed if Lee is going to do an update to DBP for Reloaded. From the sounds of his blog, he was having memory issues. Maybe this is partially the reason?
Phaelax
DBPro Master
23
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 18th Jun 2013 05:06
If I understand the reasoning for this correctly, its more efficient grabbing integers on modern architecture than single bytes. So Byte values are stored in integers and then are either casted to bytes or have their bits masked/shifted.

Kind of a rough explanation and not 100% positive, but I think its something like that.

Login to post a reply

Server time is: 2026-07-06 16:48:54
Your offset time is: 2026-07-06 16:48:54