Efficient Data Access

dbarber

New member
Joined
Oct 18, 2007
Messages
4
Programming Experience
5-10
I am using ODBC to connect to an MSSQL database. I am polling the database every 100ms to check sensor data that is being logged. I really want to minimize the resources that the program uses as much as possible.

Right now I am using an odbc.DataReader and an odbc.OdbcCommand to pull the data from the table. I don't have a need to hold the data in a DataSet. I pull the data, do some basic calculations, and come around for the next sample. Does anyone have suggestions about how to pull this data as efficiently as possible and avoid any memory leaks?
 
ditch odbc, use a datareader, dont bother connecting and disconnecting from the database over this time scale
 
I am using the SQLClient objects now and the only thing that I am opening and closing is the data reader so I can pull the data each time. I also changed the polling time to 500ms.

The program still takes up an inordinate amount of memory. Here is what I am doing:

Form Load:
Open Connection
Build Query

Timer(500ms loop):
DataReader Query DB
Display Data
Close DataReader


Other than that the only code is what was inserted by VB in the beginning, and it is still using 20k+ memory from the get go. Is there anything I can do to optimize this?
 
20 kilobytes? that's pretty low for a .NET program. Stop fussing over things you wouldnt care about if TaskManager never included a column of misleading numbers in the first place. Either that, or really go read up on how memory management works in windows and the .NET CLR, bore yourself to tears, but know why the numbers are largely meaningless at the end of the day. Then reflect that you could have better spent the time playing tennis, or soemthing :)
 
Well..thanks for that lol. What I mean by 20k (k meaning x1000) was 20,000K. If it was 20 kilobytes I would be more than happy, but 20,000 seems excessive.

When did you want to hit the court?
 
Well..thanks for that lol. What I mean by 20k (k meaning x1000) was 20,000K. If it was 20 kilobytes I would be more than happy, but 20,000 seems excessive.
.NET apps are big, because they are effectively an emulator.. Like the Java virtual machine.. They also garbage collect ona lazy bassis, because it's an expensive operation.. Programs on a windows machine typically dont clear up after themselves unless told to do so; it makes things faster.. Start a couple of photoshops and the memory use of your .NET app will shrink as the system needs the space for other things. Also leave it a time.. one of my apps consumes 30 megs of memory and all it does is post a system tray icon and show a menu to start certain apps. Over time this comes down to a couple of megs.. The numbers you see are largely ill representative of the memory a process is using too.. CPU utilisation would be a far greater concern to me..

When did you want to hit the court?
Ha ha.. well.. its a wee bit dark now for tennis by the time I get out of work most days (kim still there now, 2210 hours) but I play badminton and squash on winter nights... Gotta go cook my dinner now though.. Whever youre round this way, i guess :)
 
Good info to know...looks like I will be doing some .NET research.

I am game for some badminton. It probably needs to be a weekend, because you work too late during the week.
 
Back
Top