Rob Dye wrote:
> In article <8njcc3$lf3$1@pegasus.csx.cam.ac.uk>, gb119@cus.cam.ac.uk (Gavin
> Burnell) wrote:
>> I've got a similar problem (albeit much much worse) with a large
>> project that does extensive vi-server, queue and notifier
>> handling. After several hours of the usage it's eaten up most of the
>> available memory. The delay comes when the program is stopped -
>> LabVIEW just sits at 100% processor and takes up to 45 minutes to
>> recover. Interestingly enough Win9x doesn't have this problem and will
>> stop quickly.
> I suspect that you have a VI Reference leak in your code.
Yes, this was the first place I looked
🙂> If you open a VI Ref (using Open VI Reference) and do not release it (with
> Close VI Reference) LabVIEW will clean up and release it for you when your
> program stops. In the process of releasing a VI Ref, LabVIEW must check all
> other references to the same VI to see whether there are still any reasons
> for keeping around various resources that the VI may have allocated. This
> is, unfortunately, an O(n^2) algorithm. (The n^2 part of the cleanup was new
> to LV 5.1 and remains in LV 6i.)
> If you are opening VI Refs in a loop and failing to close them with each
> iteration, you are allocating a new VI Ref each time through the loop,
> making n a very large number, which in turn makes n^2 a nastily large
> number.
> Just close each reference at the end of each iteration of the loop.
> Or, better yet, open the reference once outside the loop, use the same
> reference during each iteration, and close it outside once the loop has
> completed. This not only avoids large n for the O(n^2) cleanup, but avoids
> the overhead of multiple Open VI Reference calls, which, if it must load the
> VI from disk, can be significant.
Actually I'm using a separate vi that runs in parallel with the main
vi and communicates via queues to do all the vi reference openning and
closing, so I can be sure that I'm only openning vi-references once
and closing them afterwards (this is because dynamically run vis
call other vis dynamically and if I didn't move the vi ref handling to
a separate vi I would spend all my time loading + unloading
vis). Actually I see a large delay after I have closed all the open vi
references, when I would have thought that any vi-references left
floating around would all be invalid so shouldn't be involved in the
garbage collection. Smaller test programs which use the same
architecture to manage the vi-refs don't have the problem and neither
does the same program on a Win9x platform. Also this problem has been
around since LV 5.0 so I don't think it is the n^2 cleanup if I read
your post correctly.
--
******************************************************************************
Gavin Burnell Dept. Materials Science and Metallurgy Device Materials
Group University of Cambridge, UK
******************************************************************************
--
Gavin Burnell
Condensed Matter Physics Group, University of Leeds, UK
http://www.stoner.leeds.ac.uk/