Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
動的メモリ割り当てについて私が学んだことから、ヒープは、好きなだけ使用できるメモリの豊富なプールのように見えます。私の質問は、変数とオブジェクトに常にヒープを使用し、スタックを忘れないのはなぜですか?
パフォーマンスの観点から、スタックへの割り当ては「無料」です。ヒープ割り当ては比較的高価です。
また、概念的には、スコープ外になった直後にオブジェクトを破棄することが容易になります。