Csound Csound-dev Csound-tekno Search About

[Cs-dev] Csound memory allocation functions

Date2014-10-15 20:06
FromEdward Costello
Subject[Cs-dev] Csound memory allocation functions
Hi,

I was just wondering is it best practice to use Csounds malloc/calloc etc. rather than the ones in the the standard C library, and if so why?
Thanks
Ed
------------------------------------------------------------------------------
Comprehensive Server Monitoring with Site24x7.
Monitor 10 servers for $9/Month.
Get alerted through email, SMS, voice calls or mobile push notifications.
Take corrective actions from your mobile device.
http://p.sf.net/sfu/Zoho
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net

Date2014-10-15 20:10
FromVictor Lazzarini
SubjectRe: [Cs-dev] Csound memory allocation functions
yes, unless you are using it for a very short time.
========================
Dr Victor Lazzarini
Dean of Arts, Celtic Studies and Philosophy,
Maynooth University,
Maynooth, Co Kildare, Ireland
Tel: 00 353 7086936
Fax: 00 353 1 7086952 

On 15 Oct 2014, at 20:06, Edward Costello  wrote:

> Hi,
> 
> I was just wondering is it best practice to use Csounds malloc/calloc etc. rather than the ones in the the standard C library, and if so why?
> Thanks
> Ed
> ------------------------------------------------------------------------------
> Comprehensive Server Monitoring with Site24x7.
> Monitor 10 servers for $9/Month.
> Get alerted through email, SMS, voice calls or mobile push notifications.
> Take corrective actions from your mobile device.
> http://p.sf.net/sfu/Zoho
> _______________________________________________
> Csound-devel mailing list
> Csound-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/csound-devel


------------------------------------------------------------------------------
Comprehensive Server Monitoring with Site24x7.
Monitor 10 servers for $9/Month.
Get alerted through email, SMS, voice calls or mobile push notifications.
Take corrective actions from your mobile device.
http://p.sf.net/sfu/Zoho
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net

Date2014-10-15 20:17
FromSteven Yi
SubjectRe: [Cs-dev] Csound memory allocation functions
I would venture to say it would be best to use all of the time.
Csound's memalloc code will track memory that is allocated and free it
(if not explicitly freed already) when csound is reset.  Also, it is
possible to replace csound's memory allocation functions with others;
a host might want to implement their own memory allocation strategy
and set that on the Csound instance. If the opcode does not use
csound->Malloc, then it won't use that strategy.

On Wed, Oct 15, 2014 at 3:10 PM, Victor Lazzarini
 wrote:
> yes, unless you are using it for a very short time.
> ========================
> Dr Victor Lazzarini
> Dean of Arts, Celtic Studies and Philosophy,
> Maynooth University,
> Maynooth, Co Kildare, Ireland
> Tel: 00 353 7086936
> Fax: 00 353 1 7086952
>
> On 15 Oct 2014, at 20:06, Edward Costello  wrote:
>
>> Hi,
>>
>> I was just wondering is it best practice to use Csounds malloc/calloc etc. rather than the ones in the the standard C library, and if so why?
>> Thanks
>> Ed
>> ------------------------------------------------------------------------------
>> Comprehensive Server Monitoring with Site24x7.
>> Monitor 10 servers for $9/Month.
>> Get alerted through email, SMS, voice calls or mobile push notifications.
>> Take corrective actions from your mobile device.
>> http://p.sf.net/sfu/Zoho
>> _______________________________________________
>> Csound-devel mailing list
>> Csound-devel@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>
>
> ------------------------------------------------------------------------------
> Comprehensive Server Monitoring with Site24x7.
> Monitor 10 servers for $9/Month.
> Get alerted through email, SMS, voice calls or mobile push notifications.
> Take corrective actions from your mobile device.
> http://p.sf.net/sfu/Zoho
> _______________________________________________
> Csound-devel mailing list
> Csound-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/csound-devel

------------------------------------------------------------------------------
Comprehensive Server Monitoring with Site24x7.
Monitor 10 servers for $9/Month.
Get alerted through email, SMS, voice calls or mobile push notifications.
Take corrective actions from your mobile device.
http://p.sf.net/sfu/Zoho
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net

Date2014-10-15 20:34
FromEdward Costello
SubjectRe: [Cs-dev] Csound memory allocation functions
Thanks, I’ll be sure to just use them always then, do you still have to explicitly call csound->Free if you used csound->Malloc? If for instance you allocate data for an array output from an opcode, do you need to register a de-init callback and free that memory using csound->Free?


> On 15 Oct 2014, at 21:17, Steven Yi  wrote:
> 
> I would venture to say it would be best to use all of the time.
> Csound's memalloc code will track memory that is allocated and free it
> (if not explicitly freed already) when csound is reset.  Also, it is
> possible to replace csound's memory allocation functions with others;
> a host might want to implement their own memory allocation strategy
> and set that on the Csound instance. If the opcode does not use
> csound->Malloc, then it won't use that strategy.
> 
> On Wed, Oct 15, 2014 at 3:10 PM, Victor Lazzarini
>  wrote:
>> yes, unless you are using it for a very short time.
>> ========================
>> Dr Victor Lazzarini
>> Dean of Arts, Celtic Studies and Philosophy,
>> Maynooth University,
>> Maynooth, Co Kildare, Ireland
>> Tel: 00 353 7086936
>> Fax: 00 353 1 7086952
>> 
>> On 15 Oct 2014, at 20:06, Edward Costello  wrote:
>> 
>>> Hi,
>>> 
>>> I was just wondering is it best practice to use Csounds malloc/calloc etc. rather than the ones in the the standard C library, and if so why?
>>> Thanks
>>> Ed
>>> ------------------------------------------------------------------------------
>>> Comprehensive Server Monitoring with Site24x7.
>>> Monitor 10 servers for $9/Month.
>>> Get alerted through email, SMS, voice calls or mobile push notifications.
>>> Take corrective actions from your mobile device.
>>> http://p.sf.net/sfu/Zoho
>>> _______________________________________________
>>> Csound-devel mailing list
>>> Csound-devel@lists.sourceforge.net
>>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>> 
>> 
>> ------------------------------------------------------------------------------
>> Comprehensive Server Monitoring with Site24x7.
>> Monitor 10 servers for $9/Month.
>> Get alerted through email, SMS, voice calls or mobile push notifications.
>> Take corrective actions from your mobile device.
>> http://p.sf.net/sfu/Zoho
>> _______________________________________________
>> Csound-devel mailing list
>> Csound-devel@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/csound-devel
> 
> ------------------------------------------------------------------------------
> Comprehensive Server Monitoring with Site24x7.
> Monitor 10 servers for $9/Month.
> Get alerted through email, SMS, voice calls or mobile push notifications.
> Take corrective actions from your mobile device.
> http://p.sf.net/sfu/Zoho
> _______________________________________________
> Csound-devel mailing list
> Csound-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/csound-devel


------------------------------------------------------------------------------
Comprehensive Server Monitoring with Site24x7.
Monitor 10 servers for $9/Month.
Get alerted through email, SMS, voice calls or mobile push notifications.
Take corrective actions from your mobile device.
http://p.sf.net/sfu/Zoho
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listi

Date2014-10-15 20:43
FromVictor Lazzarini
SubjectRe: [Cs-dev] Csound memory allocation functions
yes. But you should use AuxAlloc instead of Malloc etc in opcodes, and then you don’t need to free it.
AuxAlloc should be used because it’s the right memory mechanism for opcodes.

Regards
========================
Dr Victor Lazzarini
Dean of Arts, Celtic Studies and Philosophy,
Maynooth University,
Maynooth, Co Kildare, Ireland
Tel: 00 353 7086936
Fax: 00 353 1 7086952 

On 15 Oct 2014, at 20:34, Edward Costello  wrote:

> Thanks, I’ll be sure to just use them always then, do you still have to explicitly call csound->Free if you used csound->Malloc? If for instance you allocate data for an array output from an opcode, do you need to register a de-init callback and free that memory using csound->Free?
> 
> 
>> On 15 Oct 2014, at 21:17, Steven Yi  wrote:
>> 
>> I would venture to say it would be best to use all of the time.
>> Csound's memalloc code will track memory that is allocated and free it
>> (if not explicitly freed already) when csound is reset.  Also, it is
>> possible to replace csound's memory allocation functions with others;
>> a host might want to implement their own memory allocation strategy
>> and set that on the Csound instance. If the opcode does not use
>> csound->Malloc, then it won't use that strategy.
>> 
>> On Wed, Oct 15, 2014 at 3:10 PM, Victor Lazzarini
>>  wrote:
>>> yes, unless you are using it for a very short time.
>>> ========================
>>> Dr Victor Lazzarini
>>> Dean of Arts, Celtic Studies and Philosophy,
>>> Maynooth University,
>>> Maynooth, Co Kildare, Ireland
>>> Tel: 00 353 7086936
>>> Fax: 00 353 1 7086952
>>> 
>>> On 15 Oct 2014, at 20:06, Edward Costello  wrote:
>>> 
>>>> Hi,
>>>> 
>>>> I was just wondering is it best practice to use Csounds malloc/calloc etc. rather than the ones in the the standard C library, and if so why?
>>>> Thanks
>>>> Ed
>>>> ------------------------------------------------------------------------------
>>>> Comprehensive Server Monitoring with Site24x7.
>>>> Monitor 10 servers for $9/Month.
>>>> Get alerted through email, SMS, voice calls or mobile push notifications.
>>>> Take corrective actions from your mobile device.
>>>> http://p.sf.net/sfu/Zoho
>>>> _______________________________________________
>>>> Csound-devel mailing list
>>>> Csound-devel@lists.sourceforge.net
>>>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>>> 
>>> 
>>> ------------------------------------------------------------------------------
>>> Comprehensive Server Monitoring with Site24x7.
>>> Monitor 10 servers for $9/Month.
>>> Get alerted through email, SMS, voice calls or mobile push notifications.
>>> Take corrective actions from your mobile device.
>>> http://p.sf.net/sfu/Zoho
>>> _______________________________________________
>>> Csound-devel mailing list
>>> Csound-devel@lists.sourceforge.net
>>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>> 
>> ------------------------------------------------------------------------------
>> Comprehensive Server Monitoring with Site24x7.
>> Monitor 10 servers for $9/Month.
>> Get alerted through email, SMS, voice calls or mobile push notifications.
>> Take corrective actions from your mobile device.
>> http://p.sf.net/sfu/Zoho
>> _______________________________________________
>> Csound-devel mailing list
>> Csound-devel@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/csound-devel
> 
> 
> ------------------------------------------------------------------------------
> Comprehensive Server Monitoring with Site24x7.
> Monitor 10 servers for $9/Month.
> Get alerted through email, SMS, voice calls or mobile push notifications.
> Take corrective actions from your mobile device.
> http://p.sf.net/sfu/Zoho
> _______________________________________________
> Csound-devel mailing list
> Csound-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/csound-devel


------------------------------------------------------------------------------
Comprehensive Server Monitoring with Site24x7.
Monitor 10 servers for $9/Month.
Get alerted through email, SMS, voice calls or mobile push notifications.
Take corrective actions from your mobile device.
http://p.sf.net/sfu/Zoho
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net