The only way I can think of is to add a counter for the number of nodes, which increases each time I call the add or insert methods and decreases when I call delete. You cannot make assumptions about the occupied memory, because being a linked list, you cannot guarantee that all nodes will be in one memory block (indeed, this is very unlikely).
Baltasarq
source share