Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Win32/Win64 API (native code) (https://www.delphipraxis.net/17-win32-win64-api-native-code/)
-   -   Delphi Falscher Wert bei GlobalMemoryStatus (https://www.delphipraxis.net/116527-falscher-wert-bei-globalmemorystatus.html)

Willie1 1. Jul 2008 10:31


Falscher Wert bei GlobalMemoryStatus
 
Hallo Leute,
ich habe mir schon lange eine About-Box gestrickt, die als kleine Zugabe den vorhandenen RAM-Speicher anzeigt. Ich benutze TMemoryStatus u. GlobalMemoryStatus. Auf meinem alten Rechner mit W98 und anderen mit XP wird der richtige Wert angezeigt.
Auf meinem neuen Laptop mit Vista und 3 GB Memory wird aber nur 2 GB angezeigt. Ist das ein Fehler von Delphi oder ein Bug von Vista. Kann ich mir beides eigentlich nicht vorstellen. Auf dem Begrüßungsfenster meines PC's wird richtig 3 GB angezeigt.

MfG
Willie

sirius 1. Jul 2008 10:38

Re: Falscher Wert bei GlobalMemoryStatus
 
Du benutzt eine Funktion von Windows, da kann Delphi nix für.

Ab 2GB hast du da anscheinend ein Problem (besonders wenn du ein 32-bit Programm in einem 64Bit-BS ausführst.

Zitat:

Zitat von msdn
[GlobalMemoryStatus can return incorrect information. Use the GlobalMemoryStatusEx function instead. ]


himitsu 1. Jul 2008 10:42

Re: Falscher Wert bei GlobalMemoryStatus
 
dein Programm läuft pe Standard in 'nem 3GB Modus (nur die unteren 31 Bit der Pöinter werden vewendet)

du mußt es erst so Markieren, daß Windows 3GB verwendet, ansonsten wird alles auf 2 GB runtergerundet.

http://coding.derkeiler.com/Archive/.../msg00098.html

[add]
hat nicht nur mit 64 bit zu tun .. in 32 Bit kann man auch mit bis zu 4 GB arbeiten (2^32 = 4 GB ... und maximal 3 GB für Programme, Rest nur System)

RavenIV 1. Jul 2008 10:45

Re: Falscher Wert bei GlobalMemoryStatus
 
Aus der Delphi-Hilfe zu GlobalMemoryStatus:
Zitat:

You can use the GlobalMemoryStatus function to determine how much memory your application can allocate without severely impacting other applications.

The information returned by the GlobalMemoryStatus function is volatile. There is no guarantee that two sequential calls to this function will return the same information.

On computers with more than 4 GB of memory, the GlobalMemoryStatus function can return incorrect information. Windows 2000 and later report a value of -1 to indicate an overflow. Earlier versions of Windows NT report a value that is the real amount of memory, modulo 4 GB. For this reason, use the GlobalMemoryStatusEx function instead.

On Intel x86 computers with more than 2 GB and less than 4 GB of memory, the GlobalMemoryStatus function will always return 2 GB in the dwTotalPhys member of the MEMORYSTATUS structure. Similarly, if the total available memory is between 2 and 4 GB, the dwAvailPhys member of the MEMORYSTATUS structure will be rounded down to 2 GB. If the executable is linked using the /LARGEADDRESSAWARE linker option, then the GlobalMemoryStatus function will return the correct amount of physical memory in both members.
Erklärt dies das "Fehlverhalten"?

sirius 1. Jul 2008 10:49

Re: Falscher Wert bei GlobalMemoryStatus
 
Zitat:

Zitat von himitsu
und maximal 3 GB für Programme, Rest nur System)

maximal 2GB (unter Windows) für Programme :zwinker:

Christian Seehase 1. Jul 2008 11:45

Re: Falscher Wert bei GlobalMemoryStatus
 
Moin Sirius,

Zitat:

Zitat von sirius
Zitat:

Zitat von himitsu
und maximal 3 GB für Programme, Rest nur System)

maximal 2GB (unter Windows) für Programme :zwinker:

Nein, wenn das System entsprechend gestartet wird, und die Programme dafür ausgelegt (entsprechende compiliert) sind, geht auch unter 32-Bit Windows die Verteilung 3GB/1GB statt der üblichen 2GB/2GB.

Willie1 1. Jul 2008 11:53

Re: Falscher Wert bei GlobalMemoryStatus
 
Danke Leute,
ich habe verstanden. Ich muss also TMemoryStatusEx nachbauen und GlobalMemoryStatusEx(..) mit external einbinden. Weiß jemand ab welcher Windows-Version GlobalMemoryStatusEx zur Verfügung steht, ggf. muss ich erst Windows-Version abfragen? Über die Speicherverteilung unter Vista habe ich bisher noch keine Gedanken gemacht.

Willie.

DeddyH 1. Jul 2008 12:01

Re: Falscher Wert bei GlobalMemoryStatus
 
Laut MSDN ist die Funktion ab Windows 2000 verfügbar.

Willie1 1. Jul 2008 18:47

Re: Falscher Wert bei GlobalMemoryStatus
 
jetzt fluppt es. Danke.

W.


Alle Zeitangaben in WEZ +1. Es ist jetzt 20:15 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz