构造函数调用存储在哪里?栈还是堆?

2023-12-28

创建对象并调用构造函数时,构造函数调用存储在哪里?它在堆栈上还是堆上?


构造函数调用的参数和局部变量存储在堆栈中,直到构造函数返回。

The object that the constructor creates is stored in the heap1.


1 - ... unless you have "escape analysis" enabled, and the JIT compiler can determine that the object can be safely allocated on the stack.

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

构造函数调用存储在哪里?栈还是堆? 的相关文章

随机推荐