Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Object-Pascal / Delphi-Language (https://www.delphipraxis.net/32-object-pascal-delphi-language/)
-   -   Delphi Belegung des internen FastMM abfragen? (https://www.delphipraxis.net/151402-belegung-des-internen-fastmm-abfragen.html)

himitsu 16. Mai 2010 19:41


Belegung des internen FastMM abfragen?
 
Ich versuche mal wieder über Delphi-Referenz durchsuchenGetMemoryManagerState an die Menge der Daten im Delphi-Speichermanager ranzukommen, aber egal was ich versuche, es stimmt vorne und hinten überhaupt nichts.

Aktuell bin ich hier, aber in meinem Projekt fehlen einige hundert MB. :shock:
(vorhin hatte ich sogar mal -500 MB :lol: )
Delphi-Quellcode:
Function GetMemoryLoad: Cardinal;
  Var MS: TMemoryManagerState;
    i: Integer;

  Begin
    GetMemoryManagerState(MS);
    Result := MS.TotalAllocatedLargeBlockSize
      + (MS.TotalAllocatedMediumBlockSize - MS.ReservedMediumBlockAddressSpace);
    For i := 0 to NumSmallBlockTypes - 1 do
      Result := Result - MS.SmallBlockTypeStates[i].ReservedAddressSpace
        + (MS.SmallBlockTypeStates[i].UseableBlockSize * MS.SmallBlockTypeStates[i].AllocatedBlockCount);
  End;
Das alte Delphi-Referenz durchsuchenGetHeapStatus liefert zwar "gute" Werte (TotalAllocated - Overhead),
aber es ist halt alt (deprecated).
TStringList befindet sich eine 100 MB Textdatei (Ansi), also 200 MB an Daten (Unicode eben) und dennoch werden grade Mal 50 MB angezeigt.

Wogegen der TaskManager sogar von 485 MB spricht, welches auch von GetHeapStatus in etwa bestätigt wird.


Wie berechnet man es also richtig?
(wobei es schon blöde ist, daß es in Zukunft keine nette "Übersicht" ala GetHeapStatus geben soll)

Tryer 16. Mai 2010 20:22

Re: Belegung des internen FastMM abfragen?
 
Zitat:

The allocated address space is that part of the address space that is currently in use by the application, i.e. memory that was allocated through GetMem and not yet freed. The reserved address space is the amount of address space that was obtained from the operating system for current and future use by the application, i.e. the allocated address space plus all overhead.
Belegt ist also Sum(*Allocated* + [].Count * [].InternalBlockSize), insgesamt vom System angefordert ist Sum(Reserved*).
Zur Verfügung steht Sum(Reserved*) - Sum(*Allocated* + [].Count * [].UsableBlockSize).

So würde ich es mal ausprobieren.

Grüsse, Dirk

{Edit: [].Count * [].Size}


Alle Zeitangaben in WEZ +1. Es ist jetzt 03:27 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