Hi everybody,
I made an application that make a lot of big insertion in a 3.5 CE database.
After each insertion the memory used grows up.
If I open the db before each insertion and close the connexion after, it's ok.
But I don't want this. Is there a way to "flush" the db from memory to disk
without closing it ?
Or an other workaround ?
The code :
public bool Externalize(IDialogMesures aDialogMesures)
{
Enregistrement unDBEnregistrement;
unDBEnregistrement=
DialogMesures2DBEnregistrement(aDialogMesures);
//try
//{
// myMesuresDB = new DxDatabase(maChaineDeConnection);
//}
//catch (Exception e)
//{
// Console.WriteLine("Erreur de Connection BDD" +
e.ToString());
//}
try
{
myMesuresDB.Enregistrements.InsertOnSubmit(unDBEnregistrement);
myMesuresDB.SubmitChanges();
Thread.Sleep(300);
}
catch (Exception e)
{
Console.WriteLine("Erreur d'insertion BDD" +
e.ToString());
return false;
}
//myMesuresDB.Connection.Close();
return true;
}

Signature
Marc Alzieu
Ginny Caughey MVP - 01 Aug 2008 11:42 GMT
Marc,
You could try committing the inserts periodically and see if that makes a
difference.

Signature
Ginny Caughey
Device Application Development MVP
> Hi everybody,
> I made an application that make a lot of big insertion in a 3.5 CE
[quoted text clipped - 48 lines]
> return true;
> }
Marc Alzieu - 05 Aug 2008 09:24 GMT
Thanks but just a stupid question :
How can I commit ? The "myMesuresDB.SubmitChanges();" should commit isn't it ?

Signature
Marc Alzieu
> Marc,
>
[quoted text clipped - 53 lines]
> > return true;
> > }
Ginny Caughey MVP - 05 Aug 2008 12:19 GMT
Marc,
For inserting a lot of data, I wouldn't think that Linq would be the fastest
technology. If you use SQL syntax and ADO.Net you can control how
transactions are committed. I assume with SubmitChanges, the default
behavior is to commit each insert individually instead of in batches. There
are other things you can do to improve insert performance for SQL Compact -
here's an article benchmarking different approaches:
http://www.pocketpcdn.com/articles/articles.php?&atb.set(c_id)=74&atb.set(a_id)=
11003&atb.perform(details)
But as you can see, Linq wasn't covered in these benchmark tests.

Signature
Ginny Caughey
Device Application Development MVP
> Thanks but just a stupid question :
>
[quoted text clipped - 59 lines]
>> > return true;
>> > }
Simon Hart [MVP] - 09 Aug 2008 19:11 GMT
It doesn't help to keep creating the datacontext for each insert (non
transactional). You will need to wait for the GC to kick in here as you
don't seem to be disposing the datacontext "myMesuresDB" at the end of this
method either. But of course you might be doing this in a IDisposable
pattern? I don't know as you haven't posted all of your code.
Anyway as Ginny says LINQ to great, but for bulk inserts, I would use it
with caution.
--
Simon Hart
Visual Developer - Device Application Development MVP
http://www.simonrhart.com
> Hi everybody,
> I made an application that make a lot of big insertion in a 3.5 CE
[quoted text clipped - 48 lines]
> return true;
> }