English 中文(简体)
假释申请 终止
原标题:Console Application On Termination

在我的假释申请终止时,消除记忆的最佳方法是什么?

我愿免除我申请所消耗的任何相关载荷DLLs和任何其他资源。

我想把所有东西都留给大家来保存:

我搜索了谷歌,但找不到这样做的途径。

I m not using Units in my application it just console application

program MyAPP;

{$APPTYPE CONSOLE}

uses
  Windows, SysUtils;

/// functions 
// procedures 

begin
end.
问题回答
begin

  try
    // Your entire program goes here.
  finally
    SomeFunction;
  end;

end.

如果您的申请终止了由其直接分配或由Delphi内部拨款人(目标/意向)或由模块分配的所有记忆,则由操作系统释放。

甚至申请中的记忆泄露也不是方案终止后的问题。 可以通过利用快车牌4图书馆检查记忆泄露。

视窗还应通过向诸如GDI Plus等专门图书馆发出初始化电话,释放其获得处理的物品,但在使用这些设备的地方,物体的用途已经过时之后,这些物品应人工释放。

For all in-code deallocations you should use try..finally. So your program.dpr might ideally look like:

program YourProgram;
{$APPTYPE CONSOLE}

uses
  MainUnit;

var
  main: TProgramMain
begin
  main := TProgramMain.Create;
  try
    main.Execute;
  finally
    main.Free;
  end;
end.

你没有显示你制造的物体,而是你制造的物体,相反,如果你愿意,你如何释放这些物体。

请注意,如果您的物体只是为了跳跃而消耗记忆,那么你就只能让Windows收回您的记忆,而这一副作用(如果没有的话)可能包括你的微小应用会更快地关闭。

Nevertheless, most conscientious developers choose to fully free every object they create. If you created an object like this:

  x := TMyObject.Create;

接着,你呼吁自由:

   x.Free;

如果物体是母子拥有的成分,则不需要予以释放。

如果物体为接口物体(参考数字),你就只字不提:

   x := nil;

如果所涉类型是价值类别(Double, Integer),那么你不必予以释放。

如果有关类型自动管理(记录、扼制),也不必予以释放。

如果贵物体分配更多的物体,释放这些物体的正确位置就是该物体的 des子。

这些是规则。 只是跟随他们,你将不泄露。 你的假释申请以你未指明的方式终止。 你们是否期待对你未说明的问题作出一些魔 的回答? 如果是我的话,我将确保我的申请有条不紊地结束,在正常关闭期间,我可以释放自己的资源。 如果它异常终止,那么你书写的任何“行业”区块就不会被执行。 我建议你通过您的《关闭法》采取单一步骤,确保它完全执行。

如果你张贴了你的法典的一些例子,那么本来可以作出更具体的答复。





相关问题
determining the character set to use

my delphi 2009 app has a basic translation system that uses GNUGetText. i had used some win API calls to prepare the fonts. i thought it was working correctly until recently when someone from Malta ...

Help with strange Delphi 5 IDE problems

Ok, I m going nuts here. For the last (almost) four years, I ve been putting up with some extremely bad behavior from my Delphi 5 IDE. Problems include: Seemingly random errors in coride50.bpl ...

How to write a Remote DataModule to run on a linux server?

i would like to know if there are any solution to do this. Does anyone? The big picture: I want to access data over the web, using my delphi thin clients. But i´would like to keep my server/service ...

How convert string to integer in Oxygene

In Delphi, there is a function StrToInt() that converts a string to an integer value; there is also IntToStr(), which does the reverse. These functions doesn t appear to be part of Oxygene, and I can ...

Quick padding of a string in Delphi

I was trying to speed up a certain routine in an application, and my profiler, AQTime, identified one method in particular as a bottleneck. The method has been with us for years, and is part of a "...

热门标签