From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

How to clear engine's internal cache

I did not manage to clear my memory usage (in windows task manager)
 
I look in the help but it does not work, I make this in a loop:
 
sequencefile = engine.GetSequenceFileEx (filePath);
......
engine.ReleaseSequenceFileEx(sequencefile, 0x04); //0x04 = ReleaseSeqFile_UnloadFileIfModified
 
but my memory usage does not decrease..... How Can I Do?

Message Edited by jambon on 08-30-2006 09:17 AM

0 Kudos
Message 1 of 9
(4,105 Views)
Sorry 0x4 corresponds to ReleaseSeqFile_UnloadFile
0 Kudos
Message 2 of 9
(4,081 Views)
jambon -
Windows Task manager value corresponds to something called "Working Set" which corresponds to how much memory the system has put asside for the process, so it the value might not show a decrease in memory when the file is released. A better counter value is something called private bytes.  To ensure that the memory is released, you must call ReleaseSequenceFileEx and you must release your reference to the file stored in the variable "sequencefile". If you are using a language like C# or VB.NET, the reference is not actually freed until the variable is garbage collected by the .NET framework later, so this can also be misleading.
 
Scott Richardson
Message 3 of 9
(4,075 Views)
ummm, I'm not sure to understand. If I wait for a moment the framework will garbage collected and the memory will be freed even in the task manager?
If not, how to free memory usage asside for the process ?
I make an angine.UnloadAllmodules so memory usage decreases but  my program is unloaded (what it seems normal).
 
PS : I release my reference 'sequencefile' by sequencefile.UnloadModules, is it correct?
 
0 Kudos
Message 4 of 9
(4,073 Views)

Jambon -

What language are you using?

Scott Richardson
0 Kudos
Message 5 of 9
(4,037 Views)
    C#  (I'm beginner...)
0 Kudos
Message 6 of 9
(4,021 Views)

jambon -
When you call ReleaseSequenceFileEx, the engine released its reference to the sequence file object. If you set the sequencefile variable to null or the variable goes out of scope, the reference to the sequence file object is not immediately released, but instead is given to the C# garbage collection feature and is actually released later when the garbage collection feature decides to process it later. When this reference is finally released is when the OS typically gains back the memory for the object. The idea is that you as a developer should not have to worry about memory management. This might be why the memory does not appear to be immediately released.

Scott Richardson
0 Kudos
Message 7 of 9
(4,004 Views)
Ok, but when I make ReleaseSequenceFileEx as I do above no releasing is done.
I'm going to test  null method...
0 Kudos
Message 8 of 9
(3,984 Views)

jambon -
The call to ReleaseSequenceFileEx is still necessary. The method tells the engine to release its reference to the sequence file in the engine cache. We have a cache so that the file stays in memory because the editor is using editing it or the engine is running it. Once .NET releases your reference and the engine cache reference is released via the above method call, the file should be unloaded from memory as long as no other references exist.

Scott Richardson
Message 9 of 9
(3,968 Views)