在Delphi 2009中,我需要释放变量数组吗? [英] In Delphi 2009 do I need to free variant arrays?

查看:177
本文介绍了在Delphi 2009中,我需要释放变量数组吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我有一个变量数组,它只包含简单的类型,还有一些简单类型的可能的进一步的变体数组,我需要做任何明确的释放内存的任何内容,还是全部都适用于我。我一直认为没有什么可做的,但我只是有点怀疑!

If I have a variant array which holds nothing but simple types, and possible further variant arrays of simple types, do I need to do anything explicit to free memory, or is it all taken care of for me. I've always thought there is nothing to do, but I just had a slight doubt!

推荐答案

变体是托管类型。它们由编译器的引用计数系统所有,并且不需要手动释放。

Variants are managed types. They're owned by the compiler's reference-counting system and don't need to be freed manually.

如果你做一些像一个对象类型转换为整型的东西,并存储在变体中,然后使它成为对象的唯一引用,那么在变体超出范围之前,您需要清理它,但变体本身(包括变体数组)是安全的。

If you do something convoluted like typecasting an object to an integer and storing that in the variant, and then making that the only reference to your object, then you'll want to clean that up before the variant goes out of scope, but the variant itself (including variant arrays) is safe.

这篇关于在Delphi 2009中,我需要释放变量数组吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆