是否有可能释放一个静态定义的数组? [英] Is it possible to deallocate a statically defined array?
问题描述
可以释放与静态分配定义了一个数组的内存?
Can you release the memory of an array defined with static allocation?
推荐答案
不,这是不可能的以取消分配静态分配的内存。
No, it is not possible to de-allocate statically allocated memory.
根据不同的语言(如C / C ++,使用指针),你可能能够使用这个数组用于其他目的而持有的记忆,但这样做只会的再利用的内存;内存将不会被释放的每本身的
Depending on the language (for example C/C++, using pointers) you may be able to use the memory held by this array for other purposes, but doing so will only re-use the memory; memory won't be released per-se.
此所述,这种想法重用静态存储器/比最初所定义那里变量其他变量,仅建议以帮助理解这种类型的分配的的性质。 在实践中,特别是作为一个新手,它使绝对没有意义有需要这样的功能
This said, this idea of reusing static memory for / with variables other than the variables originally defined there, is only suggested to help understand the nature of this type of allocation. In practical terms, and in particular as a novice, it makes absolutely no sense to have the need for such a feature:
- 无论是变量,预计只要有一个终身的计划结果
在这种情况下,应该声明为static - 或变量不会在某个时间内的程序执行结果需要
在这种情况下,应该动态分配(?后不久/程序初始化期间),并公布在适当的时候。
这篇关于是否有可能释放一个静态定义的数组?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!