clibRelease
说明
示例
释放 C++ 对象 Myclass
的内存
此 C++ 库有用于创建和删除 Myclass
对象的函数。使用 clibRelease
函数管理已删除对象的内存。
使用以下语句创建头文件 header.hpp
。
class Myclass{}; Myclass* createMyclass() { return new Myclass(); } void deleteMyclass(Myclass* myc) { delete myc; }
编译一个 Myclass
的接口。
clibgen.buildInterface('header.hpp','TreatObjectPointerAsScalar',true); addpath("header")
创建一个 Myclass
对象。
cppObj = clib.header.createMyclass
cppObj = Myclass with no properties.
调用 deleteMyclass
函数。对象 Myclass
仍保留在 MATLAB 工作区中。
clib.header.deleteMyclass(cppObj) whos
调用 clibRelease
以释放内存。
clibRelease(cppObj); cppObj
cppObj = handle to deleted Myclass
输入参数
cppObj
— 在 MATLAB 中创建的 C++ 对象
句柄
在 MATLAB 中创建的 C++ 对象,指定为句柄。释放底层 C++ 对象后,将无法再在 MATLAB 中进行访问,MATLAB 句柄 cppObj
将变为无效。如果再次从库中返回该对象,MATLAB 将创建一个句柄。
版本历史记录
在 R2019a 中推出
MATLAB 命令
您点击的链接对应于以下 MATLAB 命令:
请在 MATLAB 命令行窗口中直接输入以执行命令。Web 浏览器不支持 MATLAB 命令。
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)