Memory management
Question
Why isn’t there a destructor defined for LinkedListNode
objects?
Because the node contains only 8 bytes and that size is not relevant | Even if 8 bytes is a small amount, if a lot of nodes are allocated, the used memory may amount to relevant proportions | |
Because memory is freed anyway when a program ends | You might run out of memory before that happens! | |
Because we are allocating heap memory with the garbage collector which is automatically freed when it is no longer used | Correct! | |
Because we are allocating heap memory which is managed by the OS | Heap memory is not managed by the OS specifically; the program manages the allocations |
You have successfully completed this question!