Memory issue (Not enough storage is available to complete this operation ) 
Author Message
 Memory issue (Not enough storage is available to complete this operation )

I have read the other threads about this issue but none     has given me a
solution that works.

I want to dump my sql ce db into a text file.

I use a StreamWriter to write to the file. I have custom objects which is
the interface between the db and the streamwriter. The objects could be seen
as the current row in the db and there is one for each table (some tables
has arrays of these objects since a group of rows could be connected (not
more than 3 objects in an array though...). I use a SqlCeDataReader as the
db reader and for each read, a new one is executed.

I iterate through the database using this objects and write them to the file
in sequential order. My problem is that sometimes I get a SqlCeServer error:

Error Code: 8007000E
Message: Not enough storage is available to complete this operation.

In my test I have 108 records in the database. The error occurs
_sporadically_ and I get the feeling that the SqlCeDataReader/SqlCeCommand
disposal doesn't work as fast as needed.

The function that updates the object from the database has the following
code:

public static bool UpdateObject( int tIndx )
{
    string sqlCmdTxt = ... select all fields for the table
    SqlCeCommand sqlCmd;
    SqlCeDataReader rdr;

    sqlCmd = new SqlCeCommand(sqlCmdTxt, sqlConn);
    rdr = sqlCmd.ExecuteReader();

    if( rdr.Read() )
    {
           ... Set the object values
    }
    else // No such object found
    {
        sqlCmd.Dispose();
        rdr.Close();
        rdr.Dispose();
        return false;
    }
    sqlCmd.Dispose();
    rdr.Close();
    rdr.Dispose();
    return true;

Quote:
}

So this method is called 108 times in my case.

Does anyone know what could be wrong here? If anyone is interested in
helping me out here I can provide more information.

thanks,

 Peter

PS This message was also posted in CompactFramework forum DS



Sat, 17 Dec 2005 00:14:47 GMT
 Memory issue (Not enough storage is available to complete this operation )

Peter,

Most likely, your repeated creation of "heavy" objects, such as command and
reader objects, are taking up too much memory, even though you are disposing
of them. Is this the best way to handle this? Is there a way to create the
reader and command outside of your method, and continually the same two
objects? Or, better yet, can you store all of your indexes in an object,
parse that object, and return all of your data in one connection?

Creating and destroying these object 108 times is probably not the most
efficient solution.

-dan


Quote:
> I have read the other threads about this issue but none     has given me a
> solution that works.

> I want to dump my sql ce db into a text file.

> I use a StreamWriter to write to the file. I have custom objects which is
> the interface between the db and the streamwriter. The objects could be
seen
> as the current row in the db and there is one for each table (some tables
> has arrays of these objects since a group of rows could be connected (not
> more than 3 objects in an array though...). I use a SqlCeDataReader as the
> db reader and for each read, a new one is executed.

> I iterate through the database using this objects and write them to the
file
> in sequential order. My problem is that sometimes I get a SqlCeServer
error:

> Error Code: 8007000E
> Message: Not enough storage is available to complete this operation.

> In my test I have 108 records in the database. The error occurs
> _sporadically_ and I get the feeling that the SqlCeDataReader/SqlCeCommand
> disposal doesn't work as fast as needed.

> The function that updates the object from the database has the following
> code:

> public static bool UpdateObject( int tIndx )
> {
>     string sqlCmdTxt = ... select all fields for the table
>     SqlCeCommand sqlCmd;
>     SqlCeDataReader rdr;

>     sqlCmd = new SqlCeCommand(sqlCmdTxt, sqlConn);
>     rdr = sqlCmd.ExecuteReader();

>     if( rdr.Read() )
>     {
>            ... Set the object values
>     }
>     else // No such object found
>     {
>         sqlCmd.Dispose();
>         rdr.Close();
>         rdr.Dispose();
>         return false;
>     }
>     sqlCmd.Dispose();
>     rdr.Close();
>     rdr.Dispose();
>     return true;
> }

> So this method is called 108 times in my case.

> Does anyone know what could be wrong here? If anyone is interested in
> helping me out here I can provide more information.

> thanks,

>  Peter

> PS This message was also posted in CompactFramework forum DS



Sat, 17 Dec 2005 04:04:02 GMT
 Memory issue (Not enough storage is available to complete this operation )
Hi Dan!

Thanks for your reply. I can agree that this could be an performance issue,
but not an error. As long as I dispose the objects (which even that is a
overkill since the GC should find those unused objects anyway) the memory
should be re-used when needed (isn't that the definition of GC?).

I can re-use the SqlCeCommand objects by just changing it's command text,
the SqlCeDataReader however need to be reinstantiated each time since it
uses the newly created/modified SqlCeCommand ( sqlCmd.ExecuteReader() ).

What other solutions can be used here? Writing data from a db to a text file
must be a very common operation, right?

 / P



Quote:
> Peter,

> Most likely, your repeated creation of "heavy" objects, such as command
and
> reader objects, are taking up too much memory, even though you are
disposing
> of them. Is this the best way to handle this? Is there a way to create the
> reader and command outside of your method, and continually the same two
> objects? Or, better yet, can you store all of your indexes in an object,
> parse that object, and return all of your data in one connection?

> Creating and destroying these object 108 times is probably not the most
> efficient solution.

> -dan



> > I have read the other threads about this issue but none     has given me
a
> > solution that works.

> > I want to dump my sql ce db into a text file.

> > I use a StreamWriter to write to the file. I have custom objects which
is
> > the interface between the db and the streamwriter. The objects could be
> seen
> > as the current row in the db and there is one for each table (some
tables
> > has arrays of these objects since a group of rows could be connected
(not
> > more than 3 objects in an array though...). I use a SqlCeDataReader as
the
> > db reader and for each read, a new one is executed.

> > I iterate through the database using this objects and write them to the
> file
> > in sequential order. My problem is that sometimes I get a SqlCeServer
> error:

> > Error Code: 8007000E
> > Message: Not enough storage is available to complete this operation.

> > In my test I have 108 records in the database. The error occurs
> > _sporadically_ and I get the feeling that the

SqlCeDataReader/SqlCeCommand

- Show quoted text -

Quote:
> > disposal doesn't work as fast as needed.

> > The function that updates the object from the database has the following
> > code:

> > public static bool UpdateObject( int tIndx )
> > {
> >     string sqlCmdTxt = ... select all fields for the table
> >     SqlCeCommand sqlCmd;
> >     SqlCeDataReader rdr;

> >     sqlCmd = new SqlCeCommand(sqlCmdTxt, sqlConn);
> >     rdr = sqlCmd.ExecuteReader();

> >     if( rdr.Read() )
> >     {
> >            ... Set the object values
> >     }
> >     else // No such object found
> >     {
> >         sqlCmd.Dispose();
> >         rdr.Close();
> >         rdr.Dispose();
> >         return false;
> >     }
> >     sqlCmd.Dispose();
> >     rdr.Close();
> >     rdr.Dispose();
> >     return true;
> > }

> > So this method is called 108 times in my case.

> > Does anyone know what could be wrong here? If anyone is interested in
> > helping me out here I can provide more information.

> > thanks,

> >  Peter

> > PS This message was also posted in CompactFramework forum DS



Sat, 17 Dec 2005 14:12:41 GMT
 Memory issue (Not enough storage is available to complete this operation )
What I did to solve this was to call the garbage collector and tell it to
collect unused memory.

GC.Collect();

In this way I never ran out of memory.... thought the GC would handle that
itself....

 / P



Quote:
> Hi Dan!

> Thanks for your reply. I can agree that this could be an performance
issue,
> but not an error. As long as I dispose the objects (which even that is a
> overkill since the GC should find those unused objects anyway) the memory
> should be re-used when needed (isn't that the definition of GC?).

> I can re-use the SqlCeCommand objects by just changing it's command text,
> the SqlCeDataReader however need to be reinstantiated each time since it
> uses the newly created/modified SqlCeCommand ( sqlCmd.ExecuteReader() ).

> What other solutions can be used here? Writing data from a db to a text
file
> must be a very common operation, right?

>  / P



> > Peter,

> > Most likely, your repeated creation of "heavy" objects, such as command
> and
> > reader objects, are taking up too much memory, even though you are
> disposing
> > of them. Is this the best way to handle this? Is there a way to create
the
> > reader and command outside of your method, and continually the same two
> > objects? Or, better yet, can you store all of your indexes in an object,
> > parse that object, and return all of your data in one connection?

> > Creating and destroying these object 108 times is probably not the most
> > efficient solution.

> > -dan



> > > I have read the other threads about this issue but none     has given
me
> a
> > > solution that works.

> > > I want to dump my sql ce db into a text file.

> > > I use a StreamWriter to write to the file. I have custom objects which
> is
> > > the interface between the db and the streamwriter. The objects could
be
> > seen
> > > as the current row in the db and there is one for each table (some
> tables
> > > has arrays of these objects since a group of rows could be connected
> (not
> > > more than 3 objects in an array though...). I use a SqlCeDataReader as
> the
> > > db reader and for each read, a new one is executed.

> > > I iterate through the database using this objects and write them to
the
> > file
> > > in sequential order. My problem is that sometimes I get a SqlCeServer
> > error:

> > > Error Code: 8007000E
> > > Message: Not enough storage is available to complete this operation.

> > > In my test I have 108 records in the database. The error occurs
> > > _sporadically_ and I get the feeling that the
> SqlCeDataReader/SqlCeCommand
> > > disposal doesn't work as fast as needed.

> > > The function that updates the object from the database has the
following
> > > code:

> > > public static bool UpdateObject( int tIndx )
> > > {
> > >     string sqlCmdTxt = ... select all fields for the table
> > >     SqlCeCommand sqlCmd;
> > >     SqlCeDataReader rdr;

> > >     sqlCmd = new SqlCeCommand(sqlCmdTxt, sqlConn);
> > >     rdr = sqlCmd.ExecuteReader();

> > >     if( rdr.Read() )
> > >     {
> > >            ... Set the object values
> > >     }
> > >     else // No such object found
> > >     {
> > >         sqlCmd.Dispose();
> > >         rdr.Close();
> > >         rdr.Dispose();
> > >         return false;
> > >     }
> > >     sqlCmd.Dispose();
> > >     rdr.Close();
> > >     rdr.Dispose();
> > >     return true;
> > > }

> > > So this method is called 108 times in my case.

> > > Does anyone know what could be wrong here? If anyone is interested in
> > > helping me out here I can provide more information.

> > > thanks,

> > >  Peter

> > > PS This message was also posted in CompactFramework forum DS



Sat, 17 Dec 2005 20:46:52 GMT
 
 [ 4 post ] 

 Relevant Pages 

1. SQL7: Not enough storage is available to complete this operation

2. Not enough storage is available to complete this operation

3. Not enough storage is available to complete this operation

4. not enough storage is available to complete this operation

5. not enough storage is available to complete this operation

6. Error 0x8007000E - Not enough storage is available to complete this operation

7. Not enough storage is available to complete this operation

8. Not enough storage to complete this operation

9. Error: [SQL-DMO]not enough storage is available to complete this opperation

10. sorry there is not enough memory to complete this operation

11. error - There is not enough memory to complete operation

12. Not enough memory to complete operation...


 
Powered by phpBB® Forum Software