Thanks for the post! Learned a lot. Just curious about how you arrived at the number 7GB when the message list is using 1.4mb in memory? Could you elaborate on that and the way you calculated it or measured it?
Each time you add a single item to the array, you allocate a whole new array. So it's a factorial sequence. Do it 10,000 times from 0 - 10k and the memory allocated along the way is 7GB. Of course each iteration the previous array is available for garbage collection and is collected, but there you go - the effort of garbage collecting and allocating new space isn't free etc! It can also easily lead to memory fragmentation which requires more complex GC.
Hi thanks for the explanation! I would love to know more about how you can profile the memory allocation to quantitatively analyze the performance problem. Are there any good resources on this?
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Thanks for the post! Learned a lot. Just curious about how you arrived at the number 7GB when the message list is using 1.4mb in memory? Could you elaborate on that and the way you calculated it or measured it?
Each time you add a single item to the array, you allocate a whole new array. So it's a factorial sequence. Do it 10,000 times from 0 - 10k and the memory allocated along the way is 7GB. Of course each iteration the previous array is available for garbage collection and is collected, but there you go - the effort of garbage collecting and allocating new space isn't free etc! It can also easily lead to memory fragmentation which requires more complex GC.
Hi thanks for the explanation! I would love to know more about how you can profile the memory allocation to quantitatively analyze the performance problem. Are there any good resources on this?