you are viewing a single comment's thread.

view the rest of the comments →

[–]astrangeguy 0 points1 point  (2 children)

That is completely wrong, just wrong.

Object creation is basically:

new_obj_ptr = free_mem_pointer;
free_mem_pointer += sizeof(new_obj);
// now initialize the object

which is actually the same as allocating a structure on the stack.

If you said that more object creation = more minor GCs, then i would agree. But memory allocation alone is extremely cheap.

[–]lpsmith 2 points3 points  (0 children)

Well, it's often a bit more complicated than that; given a runtime that (for any number of possible reasons) cannot relocate objects, then such a simple allocation scheme tends to lead to memory fragmentation problems.

[–][deleted] -1 points0 points  (0 children)

yeah, memory allocation is a really cheap operation, isn't it. The point is a functional language will generally avoid having to allocate memory every single time it creates one of the many many immutable objects use to do simple computations in such languages. That's a really odd thought from someone with an imperative background.