DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

DIAdem to Matlab Memory Leak

 

A VBS file was written to transfer files from DIAdem to Matlab. This is a description of the issue from user.

 

The issue is a memory leak that eventually crashes the machine. 

 

We also have tried the Fix from the Knowledgebase article and so far this is not working, and would appreciate any help on the issue.

 

 

Paul

 

Following is the problem definition.

 

 

I wrote a simple script in VBS to run in DIAdem (attached below) to convert .TDMS files to Matlab data files. The script setups a query that searches for all TDMS files in the folder chosen by the user as well as any subfolders. Then, it uses the query results to register the data in each file and save as a .mat file. In the loop that makes the conversion, I clear the internal data portal each time after the matlab file is created.

 

See attached file

 

The issue is that there is some sort of memory leak that causes DIAdem to reach it's memory limit (2 GB) after processing a large number of files and not be able to load the "tdms.dll". This error requires a close and re-open of DIAdem in order to clear the memory. This error also occurs if I run the script multiple times in a row without closing DIAdem.

On a couple of occasions when this error occurred and I clicked OK, another error box would appear: "Runtime Error 226 at 0293A9F". This error required me to use the task manager to close DIAdem.

In my attempts to isolate the root cause, I have noticed some possible explanations:

1. The error occurs on a 32bit DIAdem platform running on a XP 64 bit platform. This explains why the memory limit is so much lower than the 24 GB of RAM currently installed on the data processing PC.

2. When I ran the code without saving to the matlab file, the memory leak appears to disappear or become negligible.

3. When I ran the code on a smaller data set on my personal PC, the memory leak also appears to disappear or become negligible.

Thanks for your help in this matter. Let me know if you want me to re-create the errors again and send you screen shots. It does take about 20-30 minutes to reach the memory limit.

 

 

 

 

0 Kudos
Message 1 of 2
(3,829 Views)

Hello Paul,

 

the problem that occures is related to am memory leak when the used matlab dll is loaded and released.

If DIAdem saves a matlab file this dll is loaded and unloaded which leads to the behavior you have seen.

 

There is a workaround if we keep the plugin being attached.

 

Option Explicit  'Forces the explicit declaration of all the variables in a script.
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Insert at the start of your script
dim validWritablePathToDummyMatFile : validWritablePathToDummyMatFile = "C:\temp\dummyFileToHoldDll.mat" dim holdDllStore : set holdDllStore = navigator.ConnectDataStoreByParameter("MatLab", "<filename>" & validWritablePathToDummyMatFile & "</filename><model>http://www.ni.com/DataModels/USI/TDM/1_0</model>") '
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
dim i : for i = 1 to 1000 datafileSave "C:\temp\out.mat", "MatLab" Next

 This code will open holddllStore at the start of the script and will keep this store open till the script finishes.

This means that the memory leak only occures once for every script run. This should work out for your use case.

 

Greatings

Andreas

 

Message 2 of 2
(3,786 Views)