【发布时间】:2023-04-01 11:10:01
【问题描述】:
Chromium Embedded (https://code.google.com/p/delphichromiumembedded/) 的 GuiDemo 代码泄漏了几个字节的内存。不多,但每次停止应用程序时从 FastMM 收到该消息是非常烦人的。我猜泄漏是在 Chromium 接口中。 该单元有一个初始化部分:
INITIALIZATION
CefCache := 'cache';
CefRegisterCustomSchemes := CefOnRegisterCustomSchemes;
CefRegisterSchemeHandlerFactory('dcef', '', True, TFileScheme);
日志是这样的:
A memory block has been leaked. The size is: 20
This block was allocated by thread 0x1674, and the stack trace (return addresses) at the time was:
40455E
4050A7
409C1D
405622
4050DC
4F0D7A
406598
406604
40A6C3
4F0E28
764CEE1C [BaseThreadInitThunk]
The block is currently used for an object of class: main$174$ActRec
The allocation number is: 323
--------------------------------2014/10/5 17:11:33--------------------------------
This application has leaked memory. The small block leaks are (excluding expected leaks registered by pointer):
13 - 20 bytes: main$174$ActRec x 1
问题是我不知道 main$174$ActRec 是谁。 托管演示的单元确实称为“main.pas”。但是没有其他 var 称为 'main'。
【问题讨论】:
-
为什么有人反对这个?这是一个完全合理的问题,尽管对正在发生的事情缺乏了解。单例会泄漏一点内存,而且没有清理功能,这并不奇怪。
-
SO 社区倾向于对成员无法回答的问题投反对票,因为他们认为错误可能只存在于问题中。 SO 社区也倾向于对成员能够回答的问题投反对票,因为他们认为提问者没有表现出她/他自己解决问题的努力。对于 Delphi 问题尤其如此。