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

相关文章

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

如何测试计算机的内存是否存在问题? 判断电脑内存故障的多种方法

《如何测试计算机的内存是否存在问题?判断电脑内存故障的多种方法》内存是电脑中非常重要的组件之一,如果内存出现故障,可能会导致电脑出现各种问题,如蓝屏、死机、程序崩溃等,如何判断内存是否出现故障呢?下... 如果你的电脑是崩溃、冻结还是不稳定,那么它的内存可能有问题。要进行检查,你可以使用Windows 11

Ubuntu 24.04 LTS怎么关闭 Ubuntu Pro 更新提示弹窗?

《Ubuntu24.04LTS怎么关闭UbuntuPro更新提示弹窗?》Ubuntu每次开机都会弹窗提示安全更新,设置里最多只能取消自动下载,自动更新,但无法做到直接让自动更新的弹窗不出现,... 如果你正在使用 Ubuntu 24.04 LTS,可能会注意到——在使用「软件更新器」或运行 APT 命令时,

如何提高Redis服务器的最大打开文件数限制

《如何提高Redis服务器的最大打开文件数限制》文章讨论了如何提高Redis服务器的最大打开文件数限制,以支持高并发服务,本文给大家介绍的非常详细,感兴趣的朋友跟随小编一起看看吧... 目录如何提高Redis服务器的最大打开文件数限制问题诊断解决步骤1. 修改系统级别的限制2. 为Redis进程特别设置限制

提示:Decompiled.class file,bytecode version如何解决

《提示:Decompiled.classfile,bytecodeversion如何解决》在处理Decompiled.classfile和bytecodeversion问题时,通过修改Maven配... 目录问题原因总结问题1、提示:Decompiled .class file,China编程 bytecode

Ilya-AI分享的他在OpenAI学习到的15个提示工程技巧

Ilya(不是本人,claude AI)在社交媒体上分享了他在OpenAI学习到的15个Prompt撰写技巧。 以下是详细的内容: 提示精确化:在编写提示时,力求表达清晰准确。清楚地阐述任务需求和概念定义至关重要。例:不用"分析文本",而用"判断这段话的情感倾向:积极、消极还是中性"。 快速迭代:善于快速连续调整提示。熟练的提示工程师能够灵活地进行多轮优化。例:从"总结文章"到"用

NameNode内存生产配置

Hadoop2.x 系列,配置 NameNode 内存 NameNode 内存默认 2000m ,如果服务器内存 4G , NameNode 内存可以配置 3g 。在 hadoop-env.sh 文件中配置如下。 HADOOP_NAMENODE_OPTS=-Xmx3072m Hadoop3.x 系列,配置 Nam

跨系统环境下LabVIEW程序稳定运行

在LabVIEW开发中,不同电脑的配置和操作系统(如Win11与Win7)可能对程序的稳定运行产生影响。为了确保程序在不同平台上都能正常且稳定运行,需要从兼容性、驱动、以及性能优化等多个方面入手。本文将详细介绍如何在不同系统环境下,使LabVIEW开发的程序保持稳定运行的有效策略。 LabVIEW版本兼容性 LabVIEW各版本对不同操作系统的支持存在差异。因此,在开发程序时,尽量使用