相关疑难解决方法(0)

德尔福字符串泄漏

我正在使用Delphi XE,并编写一个使用RemObjects SDK进行通信的应用程序(如果可能相关).我有FastMM调试,有时(并不总是)当我关闭它时会发出关于单个"意外内存泄漏"的警告."发生意外的内存泄漏.意外的小块泄漏是:117-124字节:UnicodeString x 1".很偶然,我得到x2报道.

现在,我的理解是字符串是引用计数,并且由于没有其他对象导致泄漏,可能导致这种情况发生的情况是什么?在这个StackOverflow问题中,人们无法找到泄漏的方法.

如果没有明显的方法,那么我将下载最新的FastMM源(它似乎不包含在XE源中).

[编辑一旦解决]找到这个的解决方案是安装FastMM源,并启用FullDebugMode来获取堆栈跟踪.

delphi delphi-xe

7
推荐指数
4
解决办法
5822
查看次数

Why does the program crash when using const string arguments?

My program has following code:

function FooBar(const s: string): string;
var
  sa: AnsiString;
begin

  // ..........................

  sa := AnsiString(s);
  sa := AnsiString(StringReplace(string(sa), '*', '=', [rfReplaceAll]));
  sa := AnsiString(StringReplace(string(sa), ' ', '+', [rfReplaceAll]));
  result := string(sa);

  // ..........................

end;
Run Code Online (Sandbox Code Playgroud)

I noticed that the program did crash "somewhere" and FastMM4 said that I had written to a freed object. As soon as I have commented out "const", the program did work.

I have read the Delphi documentation about const arguments, but I …

memory delphi string crash const

6
推荐指数
1
解决办法
467
查看次数

如何最终确定threadvar字符串以防止泄漏?

这不是一个主要的泄漏,但更多的是我认为整洁的好,但我发现我的Delphi XE代码可以泄漏一个字符串.这是因为它被定义为threadvar,因为它需要,但是当线程终止时,它显然没有整理这些变量.

有没有办法在线程终止时手动整理字符串?我只是为它分配一个空字符串,或将其设置为零或其他什么?

delphi delphi-xe

5
推荐指数
1
解决办法
1328
查看次数

标签 统计

delphi ×3

delphi-xe ×2

const ×1

crash ×1

memory ×1

string ×1