[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Octave Memory Management
From: |
Kai Torben Ohlhus |
Subject: |
Re: Octave Memory Management |
Date: |
Mon, 19 Aug 2019 07:30:31 +0900 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 |
On 8/19/19 6:32 AM, Thomas D. Dean wrote:
> On 8/18/19 11:36 AM, Sebastian Schöps wrote:
>> Thomas D. Dean-2 wrote
>>> I have an .oct file that I want to open a device, return the pointer to
>>> the device structure.
>>>
>>> ...
>>>
>>> Does octave keep the allocation of dev_ptr between function calls?
>>>
>>> Is it possible to use a static variable in the .cc file? Would I have
>>> to free it when the device is closed?
>>>
>>> I can post the full application if necessary.
>>>
>>> Tom Dean
>>
>> Maybe Carlo‘s old advice helps?
>> https://octave.1599824.n4.nabble.com/Persistent-dara-across-oct-files-tp4689039.html
>>
>>
>> Seb.
>
> Carlo's answer is static variables.
>
> That gets me mostly there. I am opening a USB device.
>
> A clear("all") most likely destroys the instance of the static variable.
> A subsequent call to the function results in
> usb_claim_interface error -6
>
> This most likely results in a memory leak of the size of a device
> structure.
>
> Is there any way to implement a "call on clear" or
> "call on function removal" function. Sort of like a device callback
> function? Google is not much help.
>
> Tom Dean
>
>
Your description reminds me of the "onCleanup" function [1]. If you
wrap your oct-files in some m-file code, you should be able to define
some onCleanup action in case your wrapper object is cleared.
HTH,
Kai
[1] https://octave.org/doc/v5.1.0/XREFonCleanup.html