I'm having a strange problem with my VI, and I suspect that at least one of the reasons is that there's a memory leak.
Basically, the function of the VI is to send initialisation data to a device via a C DLL, and whenever the dll sets an occurrence, to read data back from the dll. If no occurrences are seen for a certain amount of time, the VI times out and reports an error.
The problem first arose because sometimes the VI would work perfectly, and other times it would only see the first few occurrences. Eventually I realised that it was related to how long LabVIEW had been running: past a certain amount of time, my VI would only notice occurrences slowly - eg. every 1s instead of every 10ms or so. Notice that this isn't related to how long the VI itself has been running, just how long LabVIEW has been running - or in other words, how long the VI has been loaded in memory for.
Trying to investigate further, I discovered that the as the VI runs, the amount of memory that LabVIEW is using (as measured by the task manager) increases steadily - at some points, up to 1Mb per second. Which indicates a memory leak - but the profiler doesn't seem to show anything odd. In addition, when the VI stops running, the amount of memory being used by LabVIEW drops, but not to the level that it was before the VI was run - generally, there's a leak of about 5Mb or more. I assume that this gradual loss of memory between VI runs is what is causing the initial slowing down process that I first noticed.
I managed to strip down the VI to a point where there is no memory leak (basically simulating occurrences in one loop, and detecting them in another), but as soon as I bring back anything real I get the memory leak back. I've looked for every leak source that I can think of, but can't find anything. For example:
- no uninitialised shift registers
- no "build array" calls
- no open calls without corresponding close calls (in fact, no open calls at all)
- no refnums are being used
- no property nodes are being used
I've tried to cut down on the number of parameters that I pass out of a loop, since that is implicitly building an array, but nothing seems to have helped.
I would post a sample VI, but there are a number of complex subVI's that are needed, and I'm not sure if I can cut it down enough to be simple enough to read while still illustrating the problem.