Diagnosing SqlCeConnection memory-load issue

Discussion in 'microsoft.public.sqlserver.ce' started by z, Jan 14, 2010.

  1. z

    z Guest

    Hi.

    I am using SQl server CE 3.0 in Windows CE 5.0, and the DB read and writes
    are working good, except that recently I have noticed that there maybe a
    memory load issue. The memory load of the system goes up, and wont go back
    down. I have a static database-Manager object that has a SqlCeConnection
    variable for the lifetime of the object which happens to be the lifetime of
    my executable that runs 24/7 on this device I am working on. So obviously the
    SqlCeConnection variable is static too, and the associated connection is
    opened in the constructor of the object, and stays open for the lifetime of
    the object/executable. Then I have getter/setter methods of this object that
    actually read/write to the database against that connection like so:

    1)string table = "some new user specified table (different every call)";
    2)SqlCeCommand cmd;
    3)cmd = conn2.CreateCommand();
    4)cmd.CommandText = "somegetter query (different every call)";
    5)cmd.ExecuteNonQuery();

    Other objects in my executable call this method over and over as need
    arises(an event happens and needs to get logged to the DB, the user changes a
    setpoint, etc...). I have noticed the problem so far with this setter mthod.
    So I am not sure about getters. So What I have noticed is that if I leave the
    code as is and crank up the frequency(100ms) of calling this method, the
    memory load just keeps going up until the system becomes unresponsive, and
    the same thing happens with lower frequency calls but it takes a lot longer
    for the system to become unresponsive. Memory load does not go back down,
    even if I stop the calls. However if I make the SqlCeConnection connetion
    object creation/open/close/destruction part of this method instead of the
    constructor then I do not see the momory load go up at all, no matter what
    the frequency. It is almost as if "conn2.CreateCommand();" keeps making the
    SqlCeConnection conn2 object fatter, which was obvioiusly not my intention or
    desire. Am I doing some unkosher coding here that hopefully is obvious to
    someone else? Should one expect the SqlCeConnection object to keep getting
    fatter in this fashion? Should I perhaps do the "conn2.CreateCommand();" in
    the constructor too and just keep changing the text on that SqlCeCommand
    object instead?

    The documentation for SqlCeConnection.CreateCommand Method says:
    "Creates and returns a SqlCeCommand object associated with the
    SqlCeConnection." I originally thought this would just return a pointer to
    the same object over and over, and now I am afraid it keeps doing "new"
    something in there.

    I monitor the memory load with "Windows CE Remote Performance Monitor" tool.
     
    z, Jan 14, 2010
    #1
    1. Advertisements

  2. Can you not dispose the command objects?

    Thanks,
    Laxmi
     
    Laxmi Narsimha Rao Oruganti [MSFT], Jan 19, 2010
    #2
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.