AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Zurück Delphi-PRAXiS Programmierung allgemein Programmieren allgemein FastMM Memory Error Detected beim Debuggen
Thema durchsuchen
Ansicht
Themen-Optionen

FastMM Memory Error Detected beim Debuggen

Ein Thema von TiGü · begonnen am 8. Aug 2012 · letzter Beitrag vom 13. Aug 2012
Antwort Antwort
Benutzerbild von haentschman
haentschman

Registriert seit: 24. Okt 2006
Ort: Seifhennersdorf / Sachsen
5.437 Beiträge
 
Delphi 12 Athens
 
#1

AW: FastMM Memory Error Detected beim Debuggen

  Alt 12. Aug 2012, 18:29
Habe es malprobiert...
Die Hints werden mit den richtigen Werten angezeigt (Caption,Text). Nach Beendigung...
Zitat:
---------------------------
TheProgram.exe: Memory Leak Detected
---------------------------
This application has leaked memory. The small block leaks are (excluding expected leaks registered by pointer):



21 - 36 bytes: UnicodeString x 1



Note: Memory leak detail is logged to a text file in the same folder as this application. To disable this memory leak check, undefine "EnableMemoryLeakReporting".


---------------------------
OK
---------------------------
Bei Beenden ohne Breakpoint kein Leak.

... interessantes Ding das.
  Mit Zitat antworten Zitat
Benutzerbild von himitsu
himitsu

Registriert seit: 11. Okt 2003
Ort: Elbflorenz
44.386 Beiträge
 
Delphi 12 Athens
 
#2

AW: FastMM Memory Error Detected beim Debuggen

  Alt 12. Aug 2012, 18:54
Stell doch erstmal dein FastMM ordentlich ein.

Speziell folgende Punkte sehn nicht so gut aus:
Zitat von deine FastMM4Options.inc:
Delphi-Quellcode:
{.$define ShareMM}

{.$define ShareMMIfLibrary}

{.$AttemptToUseSharedMM}

{Define this to enable backward compatibility for the memory manager sharing
mechanism used by Delphi 2006 and 2007, as well as older FastMM versions.}

{$define EnableBackwardCompatibleMMSharing}

Wenn dir der interne FastMM ausreichent, dann verwende einfach die SimpleShareMem.pas .


[add]
Wenn ich das ReportMemoryLeaksOnShutdown := DebugHook <> 0; in der EXE weglasse, dann gibt es keine Meldung. (XE2-Win32)
Vermutlich hängt sich hier der Debugger an den Speichermanager in der EXE, obwohl du eigentlich den der DLL nutzt.

Wenn ich das richtog gesehn hab, gibt es ein Problem in der SysUtils, wo nachdem beide MemoryManager freigegeben wurden noch versucht wird ein String freizugeben.
Probier mal was passiert, wenn du die Init-Initialisationsreihenfolge nicht durcheinanderbringst und in der DLLMain das uses MyForm; in das Interface verschiebst.
Ein Therapeut entspricht 1024 Gigapeut.

Geändert von himitsu (12. Aug 2012 um 19:33 Uhr)
  Mit Zitat antworten Zitat
TiGü

Registriert seit: 6. Apr 2011
Ort: Berlin
3.075 Beiträge
 
Delphi 10.4 Sydney
 
#3

AW: FastMM Memory Error Detected beim Debuggen

  Alt 13. Aug 2012, 09:14
Stell doch erstmal dein FastMM ordentlich ein...
Weder das Entfernen des ReportMemoryLeaksOnShutdown-Flags, noch das Verschieben der Uses-Klausel führten zum Erfolg.
Jedoch ist der Hinweis die Optionen ShareMM, ShareMMIfLibrary und AttemptToUseSharedMM zu aktivieren die Lösung!
Vielen Dank dafür!
Es müssen auch alle drei Optionen aktiviert sein.
Wenn eine fehlt, kommt es weiterhin zu dem Fehler.

Aber warum ist das so? Ich würde es gerne verstehen!
Wo kann ich mich genauer über das Thema Memory Manager informieren?
Die Doku von Emba ist etwas nichtssagend in der Hinsicht, oder aber ich finde nicht die richtigen Einträge im Wiki dazu.
Hat jemand weiterführende Lektüre?
  Mit Zitat antworten Zitat
Benutzerbild von himitsu
himitsu

Registriert seit: 11. Okt 2003
Ort: Elbflorenz
44.386 Beiträge
 
Delphi 12 Athens
 
#4

AW: FastMM Memory Error Detected beim Debuggen

  Alt 13. Aug 2012, 10:04
Bei Emba wirst du da nichts finden, denn dort ist eine "andere/spezielle Version" des FastMM integriert, welche nicht über diese INC gesteuert wird. (dort kann man aber über units wie SimpleShareMem sehr einfach vordefinierte Einstellungen für das Sharing nutzen)

Zu ShareMM, ShareMMIfLibrary und AttemptToUseSharedMM sollte was in der INC stehn und früher fand man auch Mal ein paar Infos auf der Webseite von Pierre le Riche, welche FastMM entwickelt hatte.
Ein Therapeut entspricht 1024 Gigapeut.
  Mit Zitat antworten Zitat
TiGü

Registriert seit: 6. Apr 2011
Ort: Berlin
3.075 Beiträge
 
Delphi 10.4 Sydney
 
#5

AW: FastMM Memory Error Detected beim Debuggen

  Alt 13. Aug 2012, 10:50
Zitat von Aus_der_INC-Datei:
{-----------------------Memory Manager Sharing Options------------------------}

{Allow sharing of the memory manager between a main application and DLLs that
were also compiled with FastMM. This allows you to pass dynamic arrays and
long strings to DLL functions provided both are compiled to use FastMM.
Sharing will only work if the library that is supposed to share the memory
manager was compiled with the "AttemptToUseSharedMM" option set. Note that if
the main application is single threaded and the DLL is multi-threaded that you
have to set the IsMultiThread variable in the main application to true or it
will crash when a thread contention occurs. Note that statically linked DLL
files are initialized before the main application, so the main application may
well end up sharing a statically loaded DLL's memory manager and not the other
way around. }
{.$define ShareMM}

{Allow sharing of the memory manager by a DLL with other DLLs (or the main
application if this is a statically loaded DLL) that were also compiled with
FastMM. Set this option with care in dynamically loaded DLLs, because if the
DLL that is sharing its MM is unloaded and any other DLL is still sharing
the MM then the application will crash. This setting is only relevant for
DLL libraries and requires ShareMM to also be set to have any effect.
Sharing will only work if the library that is supposed to share the memory
manager was compiled with the "AttemptToUseSharedMM" option set. Note that
if DLLs are statically linked then they will be initialized before the main
application and then the DLL will in fact share its MM with the main
application. This option has no effect unless ShareMM is also set.}
{.$define ShareMMIfLibrary}

{Define this to attempt to share the MM of the main application or other loaded
DLLs in the same process that were compiled with ShareMM set. When sharing a
memory manager, memory leaks caused by the sharer will not be freed
automatically. Take into account that statically linked DLLs are initialized
before the main application, so set the sharing options accordingly.}
{.$define AttemptToUseSharedMM}

{Define this to enable backward compatibility for the memory manager sharing
mechanism used by Delphi 2006 and 2007, as well as older FastMM versions.}
{$define EnableBackwardCompatibleMMSharing}
Soweit ich das vorher verstanden hatte, sollte sich diese Option doch nur auswirken, wenn Arrays oder normale Strings übergeben werden (nicht WideString).

In meinen Fall wird jedoch richtigerweise ein Zeiger übergeben.

Ja, selbst wenn man das Beispiel so abändert, dass einfach nur das Formular aufgerufen wird (ohne irgendetwas an die DLL zu übergeben) erhält man ja den Fehler beim Zugriff auf String-Propertys des DLLFrm.

Auch beim Zugriff auf DLLFrm.Caption oder Ähnliches gibt es die gleichen Meldungen.
Debuggen von anderen Datentypen bereiten aber keine Probleme?!?

Die FAQ zu FastMM4 haben mich auch nicht schlauer gemacht.
  Mit Zitat antworten Zitat
Antwort Antwort


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 04:20 Uhr.
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz