Is the concept of OOP intimately tied to allocating objects on the heap? Is it possible to write normal OOP without creating excessive objects on the heap?
Tell me more
×
Programmers Stack Exchange is a question and answer site for
professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.
migrated from superuser.com Jan 9 at 19:21
|
No, OOP has nothing to do with where objects reside in memory. For example, instances of the same class can be allocated statically, on the heap, or on the stack in C++. In other languages, like Python, memory management is almost transparent, so the question of location doesn't really apply. |
|||||
|
|
Technically no, but "normal OOP" assumes dynamic allocation, for which a heap is a good general-purpose mechanism. You could certainly try using some other method, but you'd probably wind up re-inventing the heap. |
|||
|
|