Custom Business objects question

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • =?Utf-8?B?WWFua2VlIEltcGVyaWFsaXN0IERvZw==?=

    Custom Business objects question

    I'm creating a lot if custom business objects. They work better, faster and
    lighter than using table adaptors. Totally cool so far except for one thing i
    just thought of: destructors. I've searched for this a little and can not
    find a good answer as to whether or not to create them nor how to use them. I
    kill all my datareaders (like a good boy should!), but i'm starting to get
    concerned about these custom objects and lists of objects i'm creating.

    1. I'm doing asp.net if it makes a difference
    2. i get the impression that they just die when they go out of scope.
    3. if they do die when out of scope can the garbage collector be told to
    free up.
    space now?
    4. It's worth noting that all my created object are dumb objects that do not
    include methods. Methods are in other classes. This does make them light, so
    should i be worried?
    Thanks
    --
    Share The Knowledge. I need all the help I can get and so do you!
  • Marc Gravell

    #2
    Re: Custom Business objects question

    1. I'm doing asp.net if it makes a difference

    Not really; the main things that make a difference are whether you are
    talking to unmanaged resources, such as handles or COM. If you aren't
    doing this, you don't need a finalizer (aka destructor, but finalizer
    is the official term for .NET). If you *were* holding an expensive
    resource, then IDisposable would be a good idea, but you don't it just
    for domain entities (data classes).
    2. i get the impression that they just die when they go out of scope.
    They become eligible for garbage collection (assuming you haven't
    linked them somewhere). When they are collected is non-deterministic,
    but if they are short-lived (typical for ASP.NET) they will be in
    "generation zero", where they can be collected very efficiently;
    the .NET garbage collector assumes that most objects are short-lived,
    and is designed to exploit this.
    3. if they do die when out of scope can the garbage collector be told to
    free up space now?
    Yes, but don't. Let the GC alone - it knows what it is doing.
    4. It's worth noting that all my created object are dumb objects that do not
    include methods. Methods are in other classes.  This does make them light, so
    should i be worried?
    That doesn't make them any lighter or heavier in terms of memory usage
    - so this isn't an issue.

    Marc

    Comment

    • =?Utf-8?B?WWFua2VlIEltcGVyaWFsaXN0IERvZw==?=

      #3
      Re: Custom Business objects question

      appreciated
      --
      Share The Knowledge. I need all the help I can get and so do you!


      "Marc Gravell" wrote:
      1. I'm doing asp.net if it makes a difference
      >
      Not really; the main things that make a difference are whether you are
      talking to unmanaged resources, such as handles or COM. If you aren't
      doing this, you don't need a finalizer (aka destructor, but finalizer
      is the official term for .NET). If you *were* holding an expensive
      resource, then IDisposable would be a good idea, but you don't it just
      for domain entities (data classes).
      >
      2. i get the impression that they just die when they go out of scope.
      >
      They become eligible for garbage collection (assuming you haven't
      linked them somewhere). When they are collected is non-deterministic,
      but if they are short-lived (typical for ASP.NET) they will be in
      "generation zero", where they can be collected very efficiently;
      the .NET garbage collector assumes that most objects are short-lived,
      and is designed to exploit this.
      >
      3. if they do die when out of scope can the garbage collector be told to
      free up space now?
      >
      Yes, but don't. Let the GC alone - it knows what it is doing.
      >
      4. It's worth noting that all my created object are dumb objects that do not
      include methods. Methods are in other classes. This does make them light, so
      should i be worried?
      >
      That doesn't make them any lighter or heavier in terms of memory usage
      - so this isn't an issue.
      >
      Marc
      >

      Comment

      Working...