Page 1 sur 1
Fichier d'échange - valeurs de retour négatives
Publié : ven. 09/mars/2007 12:58
par Jacobus
Je suis étonné que les valeurs mémoires de retour du fichier d'échange soient négatives. Quelqu'un a-t-il une idée sur la raison?
Code de test :
Code : Tout sélectionner
;Recupération des valeurs du fichier d'échange
MemoireInfo.MEMORYSTATUS
MemoireInfo\dwLength = SizeOf(MEMORYSTATUS)
GlobalMemoryStatus_(@MemoireInfo)
PageFileTotal = MemoireInfo\dwTotalPageFile / 1024 / 1024
PageFileDispo = MemoireInfo\dwAvailPageFile / 1024 / 1024
PageFileUtile = PageFileTotal - PageFileDispo
Debug PageFileTotal+" Mb" ; valeur négative!
Debug PageFileDispo+" Mb" ; valeur négative!
Debug PageFileUtile+" Mb"
Publié : ven. 09/mars/2007 13:01
par Backup
comme ça ça va mieux !!
Code : Tout sélectionner
;Recupération des valeurs du fichier d'échange
MemoireInfo.MEMORYSTATUS
MemoireInfo\dwLength = SizeOf(MEMORYSTATUS)
GlobalMemoryStatus_(@MemoireInfo)
PageFileTotal.l = MemoireInfo\dwTotalPageFile / 1024 / 1024
PageFileDispo.l = MemoireInfo\dwAvailPageFile / 1024 / 1024
PageFileUtile.l = PageFileTotal - PageFileDispo
Debug Str(PageFileTotal)+" Mb" ; valeur négative
Debug Str(PageFileDispo)+" Mb" ; valeur négative
Debug Str(PageFileUtile)+" Mb"
Publié : ven. 09/mars/2007 13:12
par Jacobus
Merci. Je croyais que PB le faisait automatiquement si on n'affectait pas les variables de ce type.
Maintenant j'obtiens ça
Debug Str(PageFileTotal)+" Mb" ; valeur négative
Debug Str(PageFileDispo)+" Mb" ; valeur positive
Debug Str(PageFileUtile)+" Mb" ; valeur négative
Publié : ven. 09/mars/2007 13:20
par Backup

pas chez moi !!
chez moi le code
Code : Tout sélectionner
;Recupération des valeurs du fichier d'échange
MemoireInfo.MEMORYSTATUS
MemoireInfo\dwLength = SizeOf(MEMORYSTATUS)
GlobalMemoryStatus_(@MemoireInfo)
PageFileTotal.l = MemoireInfo\dwTotalPageFile / 1024 / 1024
PageFileDispo.l = MemoireInfo\dwAvailPageFile / 1024 / 1024
PageFileUtile.l = PageFileTotal - PageFileDispo
Debug Str(PageFileTotal)+" Mb" ; valeur négative
Debug Str(PageFileDispo)+" Mb" ; valeur négative
Debug Str(PageFileUtile)+" Mb"
donne :

Publié : ven. 09/mars/2007 13:31
par Jacobus

C'est peut-être dû à mon proc car j'obtiens les valeurs suivantes
- 1639 Mb ; total
2018 Mb ; dispo
- 3567 MB ; utile
proc Pentium D820
Publié : ven. 09/mars/2007 14:39
par Backup
c'est bizarre !

Publié : ven. 09/mars/2007 19:17
par Flype
Avec un Quad (64Bits) pour stocker la taille au lieu d'un Long çà marchera peut être mieux. En tout cas les deux fonctionnent chez moi.
Code : Tout sélectionner
; PB4.0 - Compatible ASCII/UNICODE
Import "shlwapi.lib"
StrFormatByteSize64A(Size.q, *BufStr, BufSize.l)
EndImport
Procedure.s StrFormatByteSize(Size.q)
Protected BufStr.s = Space(255)
If StrFormatByteSize64A(Size, @BufStr, 255)
ProcedureReturn PeekS(@BufStr, -1, #PB_Ascii)
EndIf
EndProcedure
Define MemoireInfo.MEMORYSTATUSEX\dwLength = SizeOf(MEMORYSTATUSEX)
If GlobalMemoryStatusEx_(@MemoireInfo)
With MemoireInfo
Debug "TotalPhys: " + StrFormatByteSize(\ullTotalPhys)
Debug "AvailPhys: " + StrFormatByteSize(\ullAvailPhys)
Debug "TotalPageFile: " + StrFormatByteSize(\ullTotalPageFile)
Debug "AvailPageFile: " + StrFormatByteSize(\ullAvailPageFile)
Debug "TotalVirtual: " + StrFormatByteSize(\ullTotalVirtual)
Debug "AvailVirtual: " + StrFormatByteSize(\ullAvailVirtual)
Debug "AvailExtendedVirtual: " + StrFormatByteSize(\ullAvailExtendedVirtual)
EndWith
EndIf
Publié : ven. 09/mars/2007 20:07
par Jacobus
Flype, avec ton code j'obtiens effectivement des valeurs positives.
Code : Tout sélectionner
;Résultats
; TotalPhys: 0,99 Go
; AvailPhys: 460 Mo
; TotalPageFile: 2,39 Go
; AvailPageFile: 1,95 Go
; TotalVirtual: 1,99 Go
; AvailVirtual: 1,97 Go
; AvailExtendedVirtual: 0 octets
Mais je ne peux opérer ainsi :
Publié : sam. 10/mars/2007 13:43
par Flype
bah ? bien sûr que si, regarde :
évidemment tu ne pas soustraire les chaines de caractères du style : "9,2 Go" - "568 Mo".
mais tu peux le faire sur les membres de la structure MEMORYSTATUSEX puisque ce sont des nombres (sur 64Bits).
Code : Tout sélectionner
; PB4.0 - Compatible ASCII/UNICODE.
Import "shlwapi.lib"
StrFormatByteSize64A(Size.q, *BufStr, BufSize.l)
EndImport
Procedure.s StrFormatByteSize(Size.q)
Protected BufStr.s = Space(255)
If StrFormatByteSize64A(Size, @BufStr, 255)
ProcedureReturn PeekS(@BufStr, -1, #PB_Ascii)
EndIf
EndProcedure
Define MemoireInfo.MEMORYSTATUSEX\dwLength = SizeOf(MEMORYSTATUSEX)
If GlobalMemoryStatusEx_(MemoireInfo)
With MemoireInfo
Debug ""
Debug "Mémoire Physique"
Debug "Total: " + StrFormatByteSize(\ullTotalPhys)
Debug "Disponible: " + StrFormatByteSize(\ullAvailPhys)
Debug "Utilisée: " + StrFormatByteSize(\ullTotalPhys - \ullAvailPhys)
Debug ""
Debug "Mémoire Paginée"
Debug "Total: " + StrFormatByteSize(\ullTotalPageFile)
Debug "Disponible: " + StrFormatByteSize(\ullAvailPageFile)
Debug "Utilisée: " + StrFormatByteSize(\ullTotalPageFile - \ullAvailPageFile)
Debug ""
Debug "Mémoire Virtuelle"
Debug "Total: " + StrFormatByteSize(\ullTotalVirtual)
Debug "Disponible: " + StrFormatByteSize(\ullAvailVirtual)
Debug "Utilisée: " + StrFormatByteSize(\ullTotalVirtual - \ullAvailVirtual)
Debug ""
Debug "Mémoire Etendue: "
Debug "Disponible: " + StrFormatByteSize(\ullAvailExtendedVirtual)
Debug ""
EndWith
EndIf
Publié : sam. 10/mars/2007 14:28
par Flype
je met ici un source qui peut servir d'include ou même compilable avec tailbite. je pense que ce sera utile.
Code : Tout sélectionner
;-
;- Include: memory.pbi
;- Descript. Etat de la mémoire physique, paginée et virtuelle.
;- Compiler: PureBasic 4.0 (Quad et Ascii/Unicode supporté).
;-
;- MSDN:
;- Syntax: BOOL GlobalMemoryStatusEx(LPMEMORYSTATUSEX lpBuffer)
;- Client: Included in Windows XP and Windows 2000 Professional.
;- Server: Included in Windows Server 2003 and Windows 2000 Server.
;- Header: Declared in Winbase.h; include Windows.h.
;- Library: Use Kernel32.lib.
;-
EnableExplicit
;-
;- Private
;-
Import "shlwapi.lib"
StrFormatKBSizeA(Size.q, *BufStr, BufSize.l)
StrFormatByteSize64A(Size.q, *BufStr, BufSize.l)
EndImport
;-
;- Public
;-
ProcedureDLL.s FormatKB(Size.q)
Protected BufStr.s{64}
If StrFormatKBSizeA(Size, @BufStr, 64)
ProcedureReturn PeekS(@BufStr, -1, #PB_Ascii)
EndIf
EndProcedure
ProcedureDLL.s FormatSize(Size.q)
Protected BufStr.s{64}
If StrFormatByteSize64A(Size, @BufStr, 64)
ProcedureReturn PeekS(@BufStr, -1, #PB_Ascii)
EndIf
EndProcedure
ProcedureDLL.q TotalPhys()
Protected mse.MEMORYSTATUSEX\dwLength = SizeOf(MEMORYSTATUSEX)
If GlobalMemoryStatusEx_(mse)
ProcedureReturn mse\ullTotalPhys
EndIf
EndProcedure
ProcedureDLL.q AvailPhys()
Protected mse.MEMORYSTATUSEX\dwLength = SizeOf(MEMORYSTATUSEX)
If GlobalMemoryStatusEx_(mse)
ProcedureReturn mse\ullAvailPhys
EndIf
EndProcedure
ProcedureDLL.q UsedPhys()
Protected mse.MEMORYSTATUSEX\dwLength = SizeOf(MEMORYSTATUSEX)
If GlobalMemoryStatusEx_(mse)
ProcedureReturn (mse\ullTotalPhys - mse\ullAvailPhys)
EndIf
EndProcedure
ProcedureDLL.q TotalPageFile()
Protected mse.MEMORYSTATUSEX\dwLength = SizeOf(MEMORYSTATUSEX)
If GlobalMemoryStatusEx_(mse)
ProcedureReturn mse\ullTotalPageFile
EndIf
EndProcedure
ProcedureDLL.q AvailPageFile()
Protected mse.MEMORYSTATUSEX\dwLength = SizeOf(MEMORYSTATUSEX)
If GlobalMemoryStatusEx_(mse)
ProcedureReturn mse\ullAvailPageFile
EndIf
EndProcedure
ProcedureDLL.q UsedPageFile()
Protected mse.MEMORYSTATUSEX\dwLength = SizeOf(MEMORYSTATUSEX)
If GlobalMemoryStatusEx_(mse)
ProcedureReturn (mse\ullTotalPageFile - mse\ullAvailPageFile)
EndIf
EndProcedure
ProcedureDLL.q TotalVirtual()
Protected mse.MEMORYSTATUSEX\dwLength = SizeOf(MEMORYSTATUSEX)
If GlobalMemoryStatusEx_(mse)
ProcedureReturn mse\ullTotalVirtual
EndIf
EndProcedure
ProcedureDLL.q AvailVirtual()
Protected mse.MEMORYSTATUSEX\dwLength = SizeOf(MEMORYSTATUSEX)
If GlobalMemoryStatusEx_(mse)
ProcedureReturn mse\ullAvailVirtual
EndIf
EndProcedure
ProcedureDLL.q UsedVirtual()
Protected mse.MEMORYSTATUSEX\dwLength = SizeOf(MEMORYSTATUSEX)
If GlobalMemoryStatusEx_(mse)
ProcedureReturn (mse\ullTotalVirtual - mse\ullAvailVirtual)
EndIf
EndProcedure
ProcedureDLL.q AvailExtendedVirtual()
Protected mse.MEMORYSTATUSEX\dwLength = SizeOf(MEMORYSTATUSEX)
If GlobalMemoryStatusEx_(mse)
ProcedureReturn mse\ullAvailExtendedVirtual
EndIf
EndProcedure
;-
;- End
;-
DisableExplicit
; tests
Debug ""
Debug "Mémoire Physique"
Debug "Total: " + FormatSize(TotalPhys())
Debug "Disponible: " + FormatSize(AvailPhys())
Debug "Utilisée: " + FormatSize(UsedPhys())
Debug ""
Debug "Mémoire Paginée"
Debug "Total: " + FormatSize(TotalPageFile())
Debug "Disponible: " + FormatSize(AvailPageFile())
Debug "Utilisée: " + FormatSize(UsedPageFile())
Debug ""
Debug "Mémoire Virtuelle"
Debug "Total: " + FormatSize(TotalVirtual())
Debug "Disponible: " + FormatSize(AvailVirtual())
Debug "Utilisée: " + FormatSize(UsedVirtual())
Debug ""
Debug "Mémoire Etendue: "
Debug "Disponible: " + FormatSize(AvailExtendedVirtual())
Debug ""
Publié : sam. 10/mars/2007 17:48
par Jacobus
Merci Flype,
bah ? bien sûr que si, regarde
fatigue ou me..e dans les yeux, j'ai essayé toutes les façons sauf celle-là
