Friday, March 29, 2013

COSM .NET SQLSERVER and memory

I have an Arduino outside sending in time,temp,humidity, and tips of the rain gauge   The inside receiver has a barometer so it reports pressure and inside temp. That being said - it was a pain to keep track of all this.

I cobbled together a C# app to read the serial port and update COSM with the stats.  I like the little lines going up and down with the weather. I especially likeed the big dip as Sandy went by.

The C# desktop app was getting way to cumbersome as any DIY project - lots of text boxes and  a cluttered interface.  I was reading a question in Stackoverflow and had an ephiny  moment when the answer was to split the application into two pieces, the Logger, and a display - web or windows.  The middle piece that allowed this was a local SQL database.  So I killed off the old program and started from scratch.

A console app gets  the serial and logs it to a localdb table Then a windows app queries the database for the most current stats.  It allowed me with just a few queries to get the rain fall in the last 24 hours and high  and low temperatures for the same period.  I was having quite a bit of fun tweaking the console app to dump various weather stats.

The Downside of all this is the PC running is an ancient dual core athalon, When I bought it it had xp, in the mean time I migrated to WIN7 and then the fun started, with only the original 2 gigs of memory when I introduced sql server into the mix the system ground to almost unusability   Trying to get the console app to start (even compiled) took longer than the timeout on the query so it would error out, crash city.

I was astonished how much memory for this old box and its 184 pin DDR memory cost - For what 2 gigs cost I could get 8 gigs of DDR3 memory.  The cost of a decent machine was not in the budget so I bit the bullet and got 2 gigs to make 4 gigs on the machine.

Now I was in hog heaven - everything ran swimmingly even with tons of chrome tabs open and I went to bed and slept like a baby.

When I went to the machine this morning it was back to its old self and I  as more than a little miffed. I found the culprit soon after I opened task manager - Sql Server was using 1.9 gig of memory!!!  I know Databases like a lot of memory but this was a little excessive, in my mind.  Just to run a small table and a handful of queries.   Goggled a few Sql Server articles and that led me to the configuration item where the max memory usage could be set. Not being the least bit concerned about performance I throttled it down to 500 meg.

Now it seems like things have settled down and I am using a machine that has a modicum of performance again.

Now its back to making DLLs for COSM and Thingspeak, and polishing the code.

NOTE: in reality I am a software person, I only get enough hardware to let the IDE of the moment work.  I am definitely looking forward to my Raspberry Pi and all  the fun that is going to be.