none
Better use of memory RRS feed

  • Question

  • Hello,

    I've got an app that will have a large number of instance of an entity class in memory.

    Those instances won't deal with unmanaged resources, only .NET fields (int, string, other .NET entities, etc).

    How can I make a better use of the memory in this sitution? Does the GC will be enough to clean those instances when they came useless? Is there any pattern or practice to keep the memory as free as possible (Maybe, I don't know, use a limited array of bytes to store all the information)?

    Thanks
    Wednesday, October 22, 2008 6:18 PM

Answers

  • The garbage collector already does a very effective job with objects like that.  Helping out invariably makes the problem worse.  If you have reason to believe you are leaking memory, or generally want to find out what is consuming memory, you should use a profiler like Red Gate's Ants.
    Hans Passant.
    • Marked as answer by Zhi-Xin Ye Wednesday, October 29, 2008 11:52 AM
    Thursday, October 23, 2008 1:15 PM
    Moderator

All replies

  • Memory's so cheap today, that it's not worth spending your valuable time trying to mimimize its use.
    Wednesday, October 22, 2008 8:37 PM
  • The garbage collector already does a very effective job with objects like that.  Helping out invariably makes the problem worse.  If you have reason to believe you are leaking memory, or generally want to find out what is consuming memory, you should use a profiler like Red Gate's Ants.
    Hans Passant.
    • Marked as answer by Zhi-Xin Ye Wednesday, October 29, 2008 11:52 AM
    Thursday, October 23, 2008 1:15 PM
    Moderator