LabVIEW在打开一个新的引用,提示内存已满

2023-10-08 13:40

本文主要是介绍LabVIEW在打开一个新的引用,提示内存已满,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

LabVIEW在打开一个新的引用,提示内存已满

运行LabVIEW代码时,收到错误2 LabVIEW:内存已满。错误发生于创建一个VI的新引用时,例如(获取通知器,获取队列,打开VI引用,.NET构造函数节点,打开/创建/替换文件等)。为什么会收到此错误,如何避免?

解答: LabVIEW使用有限量的内存来存储每种类型的引用。因此,对于每种类型的引用,同时打开的数量被限制为1048575。因此,当到达这个数量后,任何在内存中创建新引用的框图函数可能会返回此错误。

编辑切换为居中

添加图片注释,不超过 140 字(可选)

这表示代码中的引用泄漏。引用没有正确关闭,并且最终1048575个同一类型的引用同时打开。尝试打开第1048576个引用时会出现此错误。要防止达到引用限制,请修改应用程序,以便在引用不再使用时使用相应的VI(例如释放通知器,释放队列,关闭引用等)来关闭引用。

Closing References in LabVIEW

Whenyou open a reference to an application, project, VI, or other reference source,LabVIEW allocates memory to store that reference. To free up the space inmemory where LabVIEW stored the reference source, you must close the reference.It is always safe to close a reference when you no longer need it. You can usethe Close Reference function (linked below) to close a reference.

VI Server References

VIServer references are reference types found under the SelectClass»VI Server shortcut menu item that appears when youright-click a property or invoke node, as shown in the following block diagram.VI Server references include references to applications, projects, libraries,controls, VIs, and so on.

编辑切换为居中

添加图片注释,不超过 140 字(可选)

Knowingwhen to close a VI Server reference and when you can safely leave a referenceopen can be difficult. However, unless you are certain you can safely leave areference open, always close references when you no longer need them.

Reference Functions

Ifyou open a reference using an Open VI Reference function, New VI function, orsimilar function, LabVIEW creates a new reference every time LabVIEW calls thereferenced VI. Close these references each time you open them to avoid creatingadditional memory allocations for each reference.

Multiple Calls toProperty and Invoke Nodes

WhenLabVIEW calls a Property or Invoke Node multiple times, LabVIEW does notprovide any method for checking whether LabVIEW returns the exact samereference for each call or allocates a new reference for each call. In thefollowing example, LabVIEW calls a Property Node multiple times, but providesno way of knowing whether the property will return the same reference each timeLabVIEW calls it.

编辑

添加图片注释,不超过 140 字(可选)

Becauseyou cannot be sure that LabVIEW does not create a new reference allocation foreach call, close these references, as shown in the following block diagram, toavoid any potential reference leaks.

编辑

添加图片注释,不超过 140 字(可选)

Reference Leaks

Ifyou do not close a reference, your application is susceptible to referenceleaks that can use up memory and slow the execution time of the application.LabVIEW automatically closes a reference when the top-level VI that opened thereference goes idle, but if the application runs for extended periods of time,the effects of reference leaks gradually increase.

Usethe following guidelines to determine which VI is a top-level VI:

§If theRun VI method runs a VI, that VI is a separate top-level VI.

§If a CallBy Reference node calls a VI, that VI is considered a subVI of the calling VIunless the VI being called is a remote VI.

§If aStart Asynchronous Call function makes a call-and-forget VI call, that VI is aseparate top-level VI.

§If aStart Asynchronous Call function makes a call-and-collect VI call, that VI isconsidered a subVI of the calling VI.

Tip Youcan use the Call Chain function (linked below) to identify the top-level VIunless you use a Start Asynchronous Call function to call the VI.

Referenceleaks to larger sources, such as VIs, projects, libraries, and so on, have agreater impact on memory usage and execution speed than references to smallersources, such as controls or objects within a VI. For example, if LabVIEW leaksa control reference, LabVIEW stores refnums and related control data in memory.However, if LabVIEW leaks a VI reference, LabVIEW stores a whole VI in memory.

IfLabVIEW leaks a VI reference, your program may behave incorrectly if you expectLabVIEW to unload the VI and reset the state of the VI for the next call. Toavoid reference leaks, close all references when you no longer need them.

Note Ifyou attempt to close a project reference, LabVIEW may not remove the project inmemory even if you close all references to that project because either theProject Explorer window is open or a library reference that contains theproject is open. You can use the Close method (linked below) to close allreferences to all items in a project.

Exceptions

ImplicitReferences and Unwired Property and Invoke Nodes

Althoughyou should usually close references when you no longer need them, you can leaveimplicit references and references returned in the referenceout terminal of unwired property and invoke nodes open,shown below, because a Close Reference function does not actually close thesereferences or remove the target objects from memory.

编辑

添加图片注释,不超过 140 字(可选)

Leaving these references open also creates a slightlycleaner block diagram by not cluttering the code with a Close Referencefunction.

Closing VIReferences that Have Child Object References

Youcan close child object references when you no longer need them, but closing theparent VI reference automatically closes child object references of that VI.However, if you close the parent VI reference before LabVIEW calls a childobject reference, the child object reference may become invalid. Make sure towire block diagram objects so each function executes in the order you want.

Inthe following example, if you close the VI reference immediately after LabVIEWopens the VI reference, the front panel reference may become invalid beforeLabVIEW can get the class name.

编辑

添加图片注释,不超过 140 字(可选)

Closethe VI reference only when you no longer need the front panel reference to makesure the front panel reference remains valid, as shown in the following blockdiagram.

编辑

添加图片注释,不超过 140 字(可选)

Inthe previous example, you do not need to close the front panel referencebecause the front panel reference closes when you close the VI reference.However, if you close the front panel reference, you must do so before closingthe VI reference. Otherwise, LabVIEW may return an error when LabVIEW attemptsto close the front panel reference.

Asynchronous Behavior of the CloseReference Function

Whenyou close a reference using the Close Reference function, LabVIEW closes andinvalidates the refnum immediately. However, LabVIEW does not alwaysimmediately dispose of the object in memory. LabVIEW may dispose of the objectwhen LabVIEW calls the Close function or anytime after LabVIEW calls the Closefunction.

Inthe following example, the Open VI Reference function loads the target VI intomemory. LabVIEW closes the reference after getting the name of the target VI.In this example, LabVIEW may dispose of the target VI in memory when LabVIEWcalls the Close function or LabVIEW may dispose of the target VIasynchronously.

编辑切换为居中

添加图片注释,不超过 140 字(可选)

Inthe previous example, closing the VI reference immediately before or inparallel to the second Open VI Reference function creates a race condition.LabVIEW may dispose of the target VI in memory before the second Open VIReference function can open a reference to the target VI. However, LabVIEW alsomay keep the target VI in memory long enough for the second Open VI Referencefunction to call the target VI.

Tip Youcan use the All VIs in Memory property to display and monitor when a VI leavesmemory.

LabVIEW、LabVIEW开发、LabVIEW编程、LabVIEW程序

上文中提到的例子和资料,均在word中的附件里,可点击下载。进一步了解,可联系们。

LabVIEW在打开一个新的引用,提示内存已满 - 北京瀚文网星科技有限公司 (bjcyck.com)

这篇关于LabVIEW在打开一个新的引用,提示内存已满的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/165678

相关文章

golang内存对齐的项目实践

《golang内存对齐的项目实践》本文主要介绍了golang内存对齐的项目实践,内存对齐不仅有助于提高内存访问效率,还确保了与硬件接口的兼容性,是Go语言编程中不可忽视的重要优化手段,下面就来介绍一下... 目录一、结构体中的字段顺序与内存对齐二、内存对齐的原理与规则三、调整结构体字段顺序优化内存对齐四、内

解决jupyterLab打开后出现Config option `template_path`not recognized by `ExporterCollapsibleHeadings`问题

《解决jupyterLab打开后出现Configoption`template_path`notrecognizedby`ExporterCollapsibleHeadings`问题》在Ju... 目录jupyterLab打开后出现“templandroidate_path”相关问题这是 tensorflo

Linux内存泄露的原因排查和解决方案(内存管理方法)

《Linux内存泄露的原因排查和解决方案(内存管理方法)》文章主要介绍了运维团队在Linux处理LB服务内存暴涨、内存报警问题的过程,从发现问题、排查原因到制定解决方案,并从中学习了Linux内存管理... 目录一、问题二、排查过程三、解决方案四、内存管理方法1)linux内存寻址2)Linux分页机制3)

Java循环创建对象内存溢出的解决方法

《Java循环创建对象内存溢出的解决方法》在Java中,如果在循环中不当地创建大量对象而不及时释放内存,很容易导致内存溢出(OutOfMemoryError),所以本文给大家介绍了Java循环创建对象... 目录问题1. 解决方案2. 示例代码2.1 原始版本(可能导致内存溢出)2.2 修改后的版本问题在

大数据小内存排序问题如何巧妙解决

《大数据小内存排序问题如何巧妙解决》文章介绍了大数据小内存排序的三种方法:数据库排序、分治法和位图法,数据库排序简单但速度慢,对设备要求高;分治法高效但实现复杂;位图法可读性差,但存储空间受限... 目录三种方法:方法概要数据库排序(http://www.chinasem.cn对数据库设备要求较高)分治法(常

SpringBoot项目中Maven剔除无用Jar引用的最佳实践

《SpringBoot项目中Maven剔除无用Jar引用的最佳实践》在SpringBoot项目开发中,Maven是最常用的构建工具之一,通过Maven,我们可以轻松地管理项目所需的依赖,而,... 目录1、引言2、Maven 依赖管理的基础概念2.1 什么是 Maven 依赖2.2 Maven 的依赖传递机

Redis多种内存淘汰策略及配置技巧分享

《Redis多种内存淘汰策略及配置技巧分享》本文介绍了Redis内存满时的淘汰机制,包括内存淘汰机制的概念,Redis提供的8种淘汰策略(如noeviction、volatile-lru等)及其适用场... 目录前言一、什么是 Redis 的内存淘汰机制?二、Redis 内存淘汰策略1. pythonnoe

Java内存泄漏问题的排查、优化与最佳实践

《Java内存泄漏问题的排查、优化与最佳实践》在Java开发中,内存泄漏是一个常见且令人头疼的问题,内存泄漏指的是程序在运行过程中,已经不再使用的对象没有被及时释放,从而导致内存占用不断增加,最终... 目录引言1. 什么是内存泄漏?常见的内存泄漏情况2. 如何排查 Java 中的内存泄漏?2.1 使用 J

Mybatis提示Tag name expected的问题及解决

《Mybatis提示Tagnameexpected的问题及解决》MyBatis是一个开源的Java持久层框架,用于将Java对象与数据库表进行映射,它提供了一种简单、灵活的方式来访问数据库,同时也... 目录概念说明MyBATis特点发现问题解决问题第一种方式第二种方式问题总结概念说明MyBatis(原名

关于Java内存访问重排序的研究

《关于Java内存访问重排序的研究》文章主要介绍了重排序现象及其在多线程编程中的影响,包括内存可见性问题和Java内存模型中对重排序的规则... 目录什么是重排序重排序图解重排序实验as-if-serial语义内存访问重排序与内存可见性内存访问重排序与Java内存模型重排序示意表内存屏障内存屏障示意表Int