07-19-2023, 01:42 PM
(07-19-2023, 10:27 AM)SagaraS Wrote:You're right, from what I can tell. O_o!(07-18-2023, 10:11 PM)SMcNeill Wrote: It's all about what's most efficient, in general cases, for the OS to read/write data. (Note that things like #pragma pack and such alters such behavior.) Generally speaking, the OS is going to write data in 4-bytes (sectors if you want) on a 32-bit App and in 8-byte sectors on a 64-bit App.And why does QB64 reserve the same variables for me on a 32-bit OS in a 32-bit APP? So always 8 bytes for each variable.
>> NOTICE I SAID APP AND NOT OS!! 64-bit OSes will still pack 32-bit programs into 4-byte sectors, rather than 8-byte sectors, so everything defaults for compatibility reasons. <<
Shouldn't that be at least 4 bytes?
I don't quite get it.
QB64 would then have to reserve something else. And the gaps are never really filled. I've already declared umpteen variables and restarted the program. On a 64-bit as well as on a 32-bit OS. With a 32-bit app as well as with a 64-bit app of the same program.
And again and again I can observe the same thing in the memory viewer.
Do you have some example code that better illustrates that the memory behaves differently?
Because I can't reproduce it no matter what I do instead.
My Visual Studio C++ app works like you say. But somehow QB64 doesn't intend to do what you're telling me.
Don't get me wrong, I know what you're saying and how the memory should work. But somehow QB64 doesn't want to keep that ^^
Older versions used to align on 4-byte boundaries with 32-bit apps. When I tested our latest version, it aligns on 8-byte boundaries -- most of the time!
PRINT _OFFSET(a), _OFFSET(b), _OFFSET(c)
Run the above, as is, without bothering to declare any variable type (it'll default to SINGLE), and see the spacing -- it's 32-bytes!
It's just another reason to keep in mind that it's all up to the OS for where/how it places your data in memory. I wouldn't trust that the space between is always going to be 8-bytes for anything. (Especially if mem usage starts to increase and the OS starts to reshuffle and pack program memory.)
WHY the 32-bit apps now appear to align on 8-byte memory spaces is a mystery to me. It may be the g++ guys tweaked something moving up from v11 to v17 (or whatever the lastest version is now). Personally, I'd just always rely on _OFFSET or MEM.OFFSET to let the program tell me where my data is in memory. If I was truly concerned about always packing things without any spaces, then I'd just declare a _MEMNEW block and micromanage placement manually.