我怀疑自由安道尔是否是处置物体的理想办法。 我走过了各种法典,像一些这样的东西。
StringList1.Free;
StringList1 := Nil;
使用。 以上一线是高技能的,还是更好做事? 这两种办法之间的区别是什么?
我怀疑自由安道尔是否是处置物体的理想办法。 我走过了各种法典,像一些这样的东西。
StringList1.Free;
StringList1 := Nil;
使用。 以上一线是高技能的,还是更好做事? 这两种办法之间的区别是什么?
Strictly speaking, to dispose of an object you only need to call Destroy
. However, if the reference is nil
, ie. has not been assigned a pointer to a valid instance of an object, this would cause an access violation, so it s recommended to call Free
instead which checks first if the passed reference is nil and does nothing in that case.
FreeAndNil
first assigns the passed reference to a temporary local variable, then assigns nil
to the passed reference, then calls Free
to dispose of the instance. The only difference between FreeAndNil
and your sequence obj.Free; obj := nil;
is that in the first case the passed reference will be nil
even if the destructor raises an exception.
贵问题中的守则可能由那些对FreeAndNil
之前,该文本已添加到RTL中。 如果你想要打字,你也可以使用<代码>FreeAndNil。 用长篇字书写,无助。
唯一的实际差异是FreeAndNil
将提及。 Nil
即使有Free
的提出。 但是,你们的信徒永远不应有任何进展,因此,我认为,这不是一件大事。
有一种常见的陷阱是FreeAndNil
。 由于它带有不定的参数,你可以穿透任何东西。 例如,你可以通过接口、记录等。 如果你犯了这一错误,你通常会最后出现奇怪的错误。
I m not going to get started on whether or not FreeAndNil
is an appropriate design choice. That topic has been covered in some depth elsewhere.
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 ...
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 ...
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 ...
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 ...
What is the equivalent of SetLength using Oxygene? I m trying to size an integer array. var listIndexes: array of integer; begin setLength(listIndexes,5); // doesn t work end;
How can I monitor or visualize memory fragmentation of a delphi application?
I have consistently had IDE problems in Delphi/C++Builder for years, with every version. I usually just reboot, recompile, etc. and move on. However, I keep seeing others say that the IDE is rock ...
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 "...