Page 1 of 1
Physically installed RAM
Posted: Sun Aug 06, 2023 10:54 am
by coco2
Currently MemoryStatus() reports the amount of RAM available to the OS as far as I understand it. Would it be possible to report the physically installed RAM? Such code in C++ is as follows:
Code: Select all
#include <windows.h>
#include <iostream>
unsigned long long MemoryInstalled()
{
unsigned long long physicalMemory = 0;
GetPhysicallyInstalledSystemMemory(&physicalMemory);
return physicalMemory;
}
using namespace std;
int main()
{
cout << "Installed RAM: " << MemoryInstalled() / (1024 * 1024) << "GB" << endl;
return EXIT_SUCCESS;
}
Re: Physically installed RAM
Posted: Sun Aug 06, 2023 11:00 am
by mk-soft
Code: Select all
size = MemoryStatus(#PB_System_TotalPhysical)
Debug "TOTAL: " + Str(size / (1024*1024)) + " MB"
Re: Physically installed RAM
Posted: Sun Aug 06, 2023 11:08 am
by coco2
It returns a value different to the physically installed RAM.
Code: Select all
size = MemoryStatus(#PB_System_TotalPhysical)
Debug "TOTAL: " + FormatNumber(size / (1024*1024*1024), 4) + " GB"
TOTAL: 31.9495 GB
The C++ code I posted will return 32GB
Re: Physically installed RAM
Posted: Sun Aug 06, 2023 11:42 am
by mk-soft
Perhaps without GPU buffer or a bug
Code: Select all
Import ""
GetPhysicallyInstalledSystemMemory(Size)
EndImport
size = MemoryStatus(#PB_System_TotalPhysical)
GetPhysicallyInstalledSystemMemory(@size2)
Debug "TOTAL PB: " + Str(size / 1024) + " kB"
Debug "TOTAL API: " + Str(size2) + " kB"
Re: Physically installed RAM
Posted: Sun Aug 06, 2023 12:14 pm
by coco2
Maybe not a bug, I think GlobalMemoryStatusEx() might be the same as PB. I read somewhere that it is the amount available to the OS.
Do you know how to import GlobalMemoryStatusEx()?
Re: Physically installed RAM
Posted: Sun Aug 06, 2023 12:23 pm
by mk-soft
You are right. Its not a bug
Code: Select all
Global info.MEMORYSTATUSEX
info\dwLength = SizeOf(MEMORYSTATUSEX)
r1 = GlobalMemoryStatusEx_(@info)
If r1
Debug "TOTAL API: " + info\ullTotalPhys
Else
Debug "Failed"
EndIf
Debug "TOTAL PB: " + MemoryStatus(#PB_System_TotalPhysical)
Re: Physically installed RAM
Posted: Mon Aug 07, 2023 3:30 am
by Bisonte
In C, no decimal place is calculated, but in your PB formula it is..... If you do the same in PB as in C, the result is the same:
Code: Select all
size = MemoryStatus(#PB_System_TotalPhysical)
Debug "TOTAL: " + FormatNumber(size / (1024*1024*1024), 0) + " GB"
Re: Physically installed RAM
Posted: Mon Aug 07, 2023 5:23 am
by coco2
The results aren't the same:
GetPhysicallyInstalledSystemMemory(): 33554432 KB
PureBasic: 33501516 KB