clibRelease
MATLAB から C++ オブジェクトを解放
説明
例
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)