J
jehugaleahsa
Hello:
A while back I wrote my own collection classes for C#. It was merely a
teaching exercise for myself.
The problem is that my collections perform drastically slower than the
built-in classes. I was able to do some performance monitoring and
came to the conclusion that a good portion of my time was being spent
in the Dispose methods I used to clear out values from my collections.
I have my collections call Dispose on their elements, so that
references get set to null. This way I don't have dangling references
holding up the garbage collector.
However, this comes at a somewhat serious runtime cost. My guess is
that the performance hit is due to Dispose being virtual (and it is in
my situation).
How do the built-in collections prevent dangling references?
Thanks for any suggestions. This isn't critical, purely academic.
~Travis
A while back I wrote my own collection classes for C#. It was merely a
teaching exercise for myself.
The problem is that my collections perform drastically slower than the
built-in classes. I was able to do some performance monitoring and
came to the conclusion that a good portion of my time was being spent
in the Dispose methods I used to clear out values from my collections.
I have my collections call Dispose on their elements, so that
references get set to null. This way I don't have dangling references
holding up the garbage collector.
However, this comes at a somewhat serious runtime cost. My guess is
that the performance hit is due to Dispose being virtual (and it is in
my situation).
How do the built-in collections prevent dangling references?
Thanks for any suggestions. This isn't critical, purely academic.
~Travis