在运行时更改VCL样式会导致内存泄漏

时间:2013-08-08 08:05:41

标签: delphi delphi-xe2 vcl-styles

在阅读this question之后,我试图让最终用户在运行时更改我的应用程序的样式。这导致非常长的内存泄漏列表,内容如下:

A memory block has been leaked. The size is: 12

This block was allocated by thread 0x130C, and the stack trace (return addresses) at
the time was: 404B3E [frxDsgnIntf.pas][System][@GetMem$qqri][1993] 454B77
[System.SysUtils][Sysutils.WideStrAlloc$qqrui] 454BB2 [System.SysUtils]
Sysutils.StrNew$qqrpxb] 53046E [Vcl.Controls][Controls.TWinControl.DestroyWnd$qqrv]
57E1C7 [Vcl.ComCtrls][Comctrls.TCustomTreeView.DestroyWnd$qqrv] A53DEE [JvComCtrls]
TJvTreeView.DestroyWnd$qqrv] 530733 [Vcl.Controls]
Controls.TWinControl.DestroyHandle$qqrv] 530703 [Vcl.Controls]
Controls.TWinControl.DestroyHandle$qqrv] 530703 [Vcl.Controls]
Controls.TWinControl.DestroyHandle$qqrv] 7552FEB6 [EnumThreadWindows] 530703
[Vcl.Controls][Controls.TWinControl.DestroyHandle$qqrv]

The block is currently used for an object of class: Unknown

几乎所有的泄漏都在frxDsgnIntf.pas,除了表单上允许用户更改样式的所有组件,并且所有组件都指向此过程:

with TdlgSettings.Create(nil) do // leak here according to FastMM report
  try
    if ShowModal = mrOk then;
  finally
    Release;
  end;

在更改样式时,是否有人知道我做错了什么或这是TStyleManager预期行为?这是在运行时更改样式的代码:

procedure TdlgSettings.cbThemeChange(Sender: TObject);
begin
  TStyleManager.TrySetStyle(cbTheme.Text); // cbTheme.Items lists all the themes which are included the application
end;

1 个答案:

答案 0 :(得分:1)

uses
Vcl.Styles, Vcl.Themes,
uFixMemOverflowVclStyle; 

LINK:http://www.delphi4arab.net/forum/showthread.php?t=9607

相关问题