View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0005111 | JEDI Code Library | JclSysInfo | public | 2010-01-15 13:33 | 2010-04-08 19:46 |
Reporter | Gerold | Assigned To | outchy | ||
Priority | normal | Severity | minor | Reproducibility | always |
Status | resolved | Resolution | fixed | ||
Product Version | Version 2.1 | ||||
Target Version | Fixed in Version | Version 2.2 | |||
Summary | 0005111: GetTotalPhysicalMemory returns wrong values | ||||
Description | On my systems (XP SP3 - 3 GB and Win 7 - 8 GB) GetTotalPhysicalMemory() returns always 2147483647. I use the following code to get the real value: {------------------------------------------------------------------------------} uses { JEDI Windows API } JwaWinBase; {------------------------------------------------------------------------------} function MyGlobalMemoryStatus(var ABuffer: TMemoryStatusEx): BOOL; stdcall; type TFNGlobalMemoryStatusEx = function(var ABuffer: TMemoryStatusEx): BOOL; stdcall; const FallbackSize = $38; // FieldOffset(TMemoryStatusEx, ullAvailExtendedVirtual) {$WRITEABLECONST ON} const Initialized: Integer = 0; FNMemStatEx: TFNGlobalMemoryStatusEx = nil; {$WRITEABLECONST OFF} var Status: TMemoryStatus; begin if Initialized = 0 then begin FNMemStatEx := TFNGlobalMemoryStatusEx(GetProcAddress(GetModuleHandle(kernel32),'GlobalMemoryStatusEx')); InterlockedIncrement(Initialized); end; if Assigned(FNMemStatEx) then begin Result := FNMemStatEx(ABuffer); end else begin if ABuffer.dwLength < FallbackSize then begin SetLastError(ERROR_INVALID_PARAMETER); Result := False; end else begin FillChar(Status, SizeOf(TMemoryStatus), 0); GlobalMemoryStatus(Status); Result := (Status.dwLength = SizeOf(TMemoryStatus)); if Result then begin FillChar(ABuffer, ABuffer.dwLength, 0); ABuffer.dwLength := FallbackSize; ABuffer.dwMemoryLoad := Status.dwMemoryLoad; with ABuffer, Status do begin TULargeInteger(ullTotalPhys).LowPart := dwTotalPhys; TULargeInteger(ullAvailPhys).LowPart := dwAvailPhys; TULargeInteger(ullTotalPageFile).LowPart := dwTotalPageFile; TULargeInteger(ullAvailPageFile).LowPart := dwAvailPageFile; TULargeInteger(ullTotalVirtual).LowPart := dwTotalVirtual; TULargeInteger(ullAvailVirtual).LowPart := dwAvailVirtual; end; end; end; end; end; {------------------------------------------------------------------------------} function GetTotalPhysicalMemory: Int64; var MemStatEx: TMemoryStatusEx; begin FillChar(MemStatEx, SizeOf(MemStatEx), 0); MemStatEx.dwLength := SizeOf(MemStatEx); if MyGlobalMemoryStatus(MemStatEx) then Result := MemStatEx.ullTotalPhys else Result := 0; end; {------------------------------------------------------------------------------} Would be nice to fix this bug. It was the first function I checked after installing the latest version of JCL and JVCL. | ||||
Additional Information | ASUS P5QPro + Intel E2180 + 3 GB RAM Windows XP Home SP3 and all updates Delphi 6 and all Updates JVCL 3.39 Complete JCL 2.11-Build 3536 | ||||
Tags | No tags attached. | ||||
Fixed in GIT commit | |||||
Fixed in SVN revision | 3213 | ||||
IDE version | Delphi 6 | ||||
Date Modified | Username | Field | Change |
---|---|---|---|
2010-01-15 13:33 | Gerold | New Issue | |
2010-01-15 13:33 | Gerold | File Added: JclSysInfo.jpg | |
2010-01-15 13:33 | Gerold | IDE version | => Delphi 6 |
2010-01-25 17:14 | Robert Rossmair | Relationship added | related to 0005135 |
2010-03-22 19:47 | outchy | Relationship replaced | has duplicate 0005135 |
2010-03-22 19:47 | outchy | Note Added: 0017320 | |
2010-03-22 19:47 | outchy | Assigned To | => outchy |
2010-03-22 19:47 | outchy | Status | new => feedback |
2010-04-08 19:46 | outchy | Fixed in revision | => 3213 |
2010-04-08 19:46 | outchy | Status | feedback => resolved |
2010-04-08 19:46 | outchy | Fixed in Version | => Version 2.2 (Subversion repository/Daily zips) |
2010-04-08 19:46 | outchy | Resolution | open => fixed |