11-12-2023, 12:49 AM
https://qb64phoenix.com/qb64wiki/index.php/TYPE <-- There's what you want, more or less.
An INTEGER is 2 bytes, so an array of DIM foo(10) AS INTEGER is 22 bytes. (From 0 to 10 is 11 elements, with each being 2 bytes in size. Don't forget that 0 element!)
_BITs are 1 byte. (Unless you're dealing with arrays, in which case they're then bit packed as tightly as possible, so DIM foo(100) AS _BIT is only _CEIL(101 / 8) bytes in size.)
_BYTEs are 1 byte.
INTEGERs are 2 bytes.
LONGs are 4 bytes.
_INTEGER64s are 8 bytes.
With that said, there's some background overhead associated with every variable in QB64, which tracks its offset in memory, what type is it, if it's available or freed, ect, ect. From what I recall, without looking it up, I *believe* that behind-the-scene data is 22-bytes per variable/array. So, if you're trying to micromanage memory usage down to account for the last byte your program uses, you'd be looking at having to account for that +22 per variable still in scope and valid. (Remember, SUBs and FUNCTIONs clean up after themselves and free those variables and all that background data as well, so those are just temporary mem users.)
An INTEGER is 2 bytes, so an array of DIM foo(10) AS INTEGER is 22 bytes. (From 0 to 10 is 11 elements, with each being 2 bytes in size. Don't forget that 0 element!)
_BITs are 1 byte. (Unless you're dealing with arrays, in which case they're then bit packed as tightly as possible, so DIM foo(100) AS _BIT is only _CEIL(101 / 8) bytes in size.)
_BYTEs are 1 byte.
INTEGERs are 2 bytes.
LONGs are 4 bytes.
_INTEGER64s are 8 bytes.
With that said, there's some background overhead associated with every variable in QB64, which tracks its offset in memory, what type is it, if it's available or freed, ect, ect. From what I recall, without looking it up, I *believe* that behind-the-scene data is 22-bytes per variable/array. So, if you're trying to micromanage memory usage down to account for the last byte your program uses, you'd be looking at having to account for that +22 per variable still in scope and valid. (Remember, SUBs and FUNCTIONs clean up after themselves and free those variables and all that background data as well, so those are just temporary mem users.)