Possible System Memory Leak, trying to eliminate DAQFactory


Recommended Posts

A windows 10 computer I have running two large DAQFactory programs is crashing in about a week due to memory running out and windows crashing (the bluescreen says)  The only real applications running are two very large DAQFactory programs (and SQL Server which is known to be a memory hog but i don't think it crashes windows).  I suspect the issue is likely something I'm doing, like a db.open without a matching db.close in a fast loop somewhere so I'm already looking for those.  Are there any hints where to look or tools built in that might help with this?  Has anyone seen issues continuously writing large amounts of debug text to the command window? I looked elsewhere in the forum and there was only one pretty dated article dealing with memory issues.

Link to comment
Share on other sites

If you are opening a database but never closing it, you will leak memory.  It will be a pretty slow leak, but after a week could use up all available memory.  Windows responds to complete loss of memory in weird ways, and a bluescreen is not unheard of.  Personally I don't close my databases.  I open them at startup and just leave them open while DAQFactory is running.  DAQFactory will close it automatically when it shuts down.  File handles often have to be closed to force Windows to clear the write cache, or to allow other applications write access to the file, but databases do not have this issue.  If you are seeing that the database appears to not be updating in another program while DAQFactory is working with it, it may be that the database is transactional and you need to perform a commit on the database.  The SQL command for this varies on the database, but for, say, Firebird, the command is just "Commit".

Link to comment
Share on other sites

  • 1 year later...

I'm trying to track down what I think is a memory leak. DF runs fine for about a day, then starts to error out that it can't run any sequences. Task Manager shows DF is using over 1GB of memory; up from about 150mb on startup.

It looks to be an issue with my logging function, which is called every 10 seconds to write all tags to MySQL. Simplified version:

	private MySQLHandle = DB.Open("dfsqlsource", "user", "pass")

	//for loops to create query, removed here for brevity
	private string SQLQuery = "INSERT INTO etc etc"
	DB.Execute(MySQLHandle, SQLQuery) 	

	System.ErrorMessage("SQL Log All Error: " + strLastError)

Am I using DB.Open() and DB.Close() correctly? Or is it something to do with the private variables staying in scope between function calls or something weird like that?

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.