Re: Disposing DataContext

From: Andrus Adamchik (andru..bjectstyle.org)
Date: Sat Dec 17 2005 - 11:27:37 EST

  • Next message: Andrus Adamchik: "Re: Programmatically switching between DataNodes"

    On Dec 17, 2005, at 8:20 AM, Howard Treisman wrote:

    > 1. Is it okay to just instantiate a DataContext each time my method
    > is called? In particular, are there any performance implications of
    > doing this? I don't have control over thread or session creation,
    > so it's difficult for me to set up the DataContext on the thread, etc.

    > 2. When my method completes, do I need to dispose or cleanup the
    > DataContext in any way? Can I just create it as a local variable,
    > and let garbage collection do its thing? Are there any memory or
    > connection leakage issues?

    I second Joshua - local DataContexts are safe. The only way this can
    leak is if you keep references to objects registered in this context.
    So if your context is local, your DataObjects should also be local,
    as they have a back reference to the DataContext.

    > As a side issue - I'm reasonably sure these questions have been
    > answered previously on the mailing list - is there any better way
    > of searching the archieves than simply clicking on each month in turn?

    "Search" field on the left of every page relies on Google and is
    normally all you need. If you want to seacrh just mailing lists you
    can go to Google directly and use this hack:

    <search term> site:objectstyle.org/cayenne/lists

    Andrus



    This archive was generated by hypermail 2.0.0 : Sat Dec 17 2005 - 11:27:43 EST