Memory usage XP embedded


Recommended Posts

I have issues with DAQ 5.79A crashing after a few days of run-time. Two things we noticed so far:

1) I noticed that the memory usage continuously increased until DAQ crashes.

During investigation we found that when you start DAQ factory it takes x-amount of memory (i.e. 40,000K) when you minimise DAQ (windows standard minimise button on title bar) the memory drops dramatically (i.e.10,000K). When restoring DAQ it raises again but only to about half of the initial (i.e. 20,000K)

When Starting DAQ from a shortcut directly into the document it takes a far larger amount of memory again (i.e. 100,000K). Again with minimise and restore it takes anywhere between 25,000K and 45,000K.

We replicated this with various sizes of DAQ documents. The memory used is always far lower after a minimise/restore and stays lower (at least for the period of testing: max a few hrs)

Now our application runs onboard mobile mining machinery and has typically no user interaction unless with remote takeover for analysis or debug reasons which could be hours or months apart.

Is there anybody that can explain this behaviour and how we could keep the memory low?

2) One of the reasons (not sure yet if the only reason) the memory usage increased seemed to be because we opened an ODBC (SQL) every 30seconds with the same line of code:

Database = db.OpenEx("DSN=ODBCName;UID=User;PWD=password")

This was done for beginners reasons not trusting the database handle/connection to remain open and stable for ever and a day. Instead expecting that re-opening with the same line it would overwrite the already established connection/handle etc. We are now catching "O...." type errors and from there closing and opening the connection. This seemed to have improved the memory usage (we will see in a few days).

Why would opening without prior closing of the database connection cause the memory to increase to the death?

I would also appreciate any tips for how to best handle ODBC connection to SQL with minimal memory usage.

Thank You in advance.

Link to comment
Share on other sites

Lets start with: what release of DAQFactory you are using?

As for memory jumping up and down, its pretty unreliable to look at task manager memory usage for memory leaks unless you fire up the program and just leave it alone. There is so much memory optimization done by windows that you can't really tell what is going on. Just try keeping firefox open for a while and open more windows. I'll often get 10 or 15 windows open and firefox will be up in the 250meg range, then I'll close all but one window showing some basic page and it still takes 250meg. Then I'll do something random and all the sudden it drops (though typically I restart). Windows keeps memory allocated to particular applications for a period after the memory is actually used to allow the application to use it again rapidly. Windows then cleans up at somewhat random times, which for DAQFactory appears to include when you minimize.

But that doesn't really solve your problem. Post your DAQFactory release number so I can identify if its an issue that has been fixed.

I will say this though, if you call db.openex() without closing it first, you are basically creating another handle to the database. The first handle is not released until DAQFactory quits. So repetitively opening a database handle will slowly chew up memory. I recommend putting your db calls inside of a try/catch to avoid this:

private dbhandle


dbhandle = db.Openex(...)





Make sure you don't stop this sequence from outside. File.Open() has the same issue, which is why we have a File.CloseAll() function so you can close files for handles you've lost track of. Perhaps we need to add a db.closeall() function too.

Link to comment
Share on other sites

Thanks for the quick response.

So its windows task manager making memory allocations not quite transparent. I am testing slowly and painfully by not touching anything for 30mins to hours and watching the task-manager for the allocation.

Does DAQ have a function to minimise/restore that can be called in a sequence?

We are running DAQFactory 5.79A Build: 1574

Link to comment
Share on other sites

If you are going to run headless you might consider running in Acquire mode, however, you cannot switch to acquire mode programmatically. You can from the menu. You can also tell the document to load in acquire mode by going to File - Document settings. Acquire mode simply eliminates the GUI except for an icon in the bottom right corner of the screen, and bumps the priority of DAQFactory into what Windows calls the Real-time priority class. Though its not true realtime, it still causes DAQFactory actions to take priority over most of windows. Because of this, make sure to only do this if you have debugged your app. If you accidently create an infinite loop, windows will completely hang and you won't be able to do anything, even Ctrl-alt-del.

Link to comment
Share on other sites

We do prefer to keep the GUI because we deploy in various scenarios where the GUI might be needed. It is somewhat out of our control whether the user looks at it or not but he must have easy access if he wants to. Nevertheless it is certainly something we need to consider.

There is nothing else in DAQ that can do the same thing as occurs when you minimise/restore?

Link to comment
Share on other sites

You can't programmatically switch between Acquire mode and regular mode, but all you have to do is click on that icon and select "Switch out of Acquire Mode". To switch back you just go File- Switch to acquire mode. You can try it right now. It couldn't really be any easier.

Link to comment
Share on other sites


This topic is now archived and is closed to further replies.