@SMcNeill Regarding free memory available...
Is there a limit, if you compile with the 64-bit version of QB64? I guess if you max out ram + hard drive usage, but that’s either one massive program or one helluva memory leak!
On my setup with 32 GByte memory (of which 10 GByte is configured as a RAM drive) with Windows 10 x64 - for my 128bit Math Code Project...
In my case it is critical that calculations are completed within a 3-day computer run session (it does not matter how many times I retry a 3-day session, just can not take longer than 3 days per run). So to this end I am evaluating various coding methods to be "time efficient" and so trying out _MEM type stuff ranging from BIT to INTEGER64 with associated timing comparisons. Because of the size of numbers and the method used to process same - I need to be mindful of how much memory is available, as my estimation for memory use is far from perfect (partly because I do not fully understand how Windows 10 allocates memory). So to avoid running into "Out of Memory" errors at run time - the reason for monitoring Free Memory Available.
As I wanted to investigate the practicality of using _UNSIGNED _BIT variables it was important to establish if a BIT array would always pack 8 bits per byte into memory (the ideal case) or if a byte was used for each bit. Below is my test program (based on
@moises1953 code)
TYPE MEMORYSTATUSEX
'MemStat FUNCTION GlobalMemoryStatusEx&
(Mstat
AS MEMORYSTATUSEX
) MemStat.dwLength
= LEN(MemStat
)Result = GlobalMemoryStatusEx&(MemStat): before&& = MemStat.ullAvailPhys
Result = GlobalMemoryStatusEx&(MemStat): after&& = MemStat.ullAvailPhys
The results for various numbers of bits (as multiples of 8 bits) as in a BIT array versus free memory loss due to the creation of the BIT array is below
[ You are not allowed to view this attachment ]
So trying to appreciate how Windows 10 allocates memory, from the larger of sizes of the BIT array it would sort of suggest to me that 8bits (in a BIT array) are packed into a byte. Of interest if I try to have a BIT array (0 TO 7999999999) i.e. 8 Giga bits I get an out of memory error at run time (even though I have (32 - 10) GBytes ram still available for system memory.
As a side note I have problems with trying to use BIT stuff, e.g. consider the statement
DIM m1 AS _UNSIGNED _BIT * 56: m1 = 0 ' this line is line... as below
looking at the number after "*" the results (IDE error)
'* 56 OK
'* 57 Compiler error (check for syntax errors) (Reference:9-21340) on line ...
'* 58 Cannot create a bit variable of sie >24 bits on line ...
'* 100 Too many characters in number after * on line ...
it would have been nice to have say DIM m1 as _UNSIGNED _BIT *1024 ' or much bigger - so I am confused with the results above.
Also, unless I am doing something wrong (quite possible), I cannot seem to be able to do something like
MEMGET m, m.offset, h~` ' i.e. any reference to a BIT variable
Similarly, trying to be fully versatile with _MEM stuff (experimental trials by me) I also have problems such as
z~%% = MEMNEW(1)::::::::: z~%% = 0 ' 1 bytes for ~%%
'In file included from qbx.cpp:2216:
'..\\temp\\main.txt: In function 'void SUB_L1_INITIALIZATION()':
'..\\temp\\main.txt:3112:59: error: cannot convert 'mem_block' to 'unsigned char' in assignment
' *_SUB_L1_INITIALIZATION_UBYTE_Z=(func156=func__memnew( 1 ));
' ^
'compilation terminated due to -Wfatal-errors.
z~% = MEMNEW(2)::::::::: z~% = 0 ' 2 bytes for ~%
'In file included from qbx.cpp:2216:
'..\\temp\\main.txt: In function 'void SUB_L1_INITIALIZATION()':
'..\\temp\\main.txt:3112:62: error: cannot convert 'mem_block' to 'short unsigned int' in assignment
' *_SUB_L1_INITIALIZATION_UINTEGER_Z=(func156=func__memnew( 2 ));
' ^
'compilation terminated due to -Wfatal-errors.
So far I think I am OK with the other variable types possibilities in the above scenarios.
Many thanks again for your informative tutorials (videos) on _MEM and my 128bit Math Code Project (NOT in competition with other forum members, or your C library link, etc) is my first application of _MEM with encouraging results (though slow at present).
Please supply any comments you may have regarding above.