because you just have to move the top of heap pointer 10,000 times. Malloc has to allocate 10,000 separate blocks instead
It's actually more complicated than that because all the object ivars have to be malloc'd as well.
On the other hand, you can sometimes avoid a lot of this overhead by doing a malloc of a large block of memory (sizeof(id) * 10000), and stuffing in the isa pointers in the appropriate places.
But yes, I understand the basic point you're making.
by Scott Stevenson — May 22
It's actually more complicated than that because all the object ivars have to be malloc'd as well.
On the other hand, you can sometimes avoid a lot of this overhead by doing a malloc of a large block of memory (sizeof(id) * 10000), and stuffing in the isa pointers in the appropriate places.
But yes, I understand the basic point you're making.