Reputation: 27265
.NET 3.5, I've got some classes which stores up to 1MB of strings. Even though I need the object for a really long time I don't need to store the string for a long time.
How can I truly remove the string from memory without disposing the parent object.
Is it a good practice to use "myString = null
" in this case? or shall wrap it in a private dsposable class or something?
Upvotes: 1
Views: 227
Reputation: 75296
It's possible that you're referencing or copying the string somewhere else in the program (like in a TextBox?), which is keeping it alive in memory.
Upvotes: 0
Reputation: 115731
IDisposable
has nothing to do with memory management. Assigning null
to a private variable will do just fine. And see if Flyweight fits you.
Upvotes: 2