Is re-using a Command and Connection object in ado.net a legitimate way of reducing new object creat

Posted by Neil Trodden on Stack Overflow See other posts from Stack Overflow or by Neil Trodden
Published on 2010-05-14T12:21:19Z Indexed on 2010/05/14 12:24 UTC
Read the original article Hit count: 251

The current way our application is written, involves creating a new connection and command object in every method that access our sqlite db. Considering we need it to run on a WM5 device, that is leading to hideous performance.

Our plan is to use just one connection object per-thread but it's also occurred to us to use one global command object per-thread too. The benefit of this is it reduces the overhead on the garbage collector created by instantiating objects all over the place.

I can't find any advice against doing this but wondered if anyone can answer definitively if this is a good or bad thing to do, and why?

© Stack Overflow or respective owner

Related posts about ADO.NET

Related posts about .net-compact-framework