Working with strings, memory allocation and GC

View: New views
2 Messages — Rating Filter:   Alert me  

Working with strings, memory allocation and GC

by Rajinder Yadav-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I understand that strings are suppose to be treated as immutable.
However if I want to mutate the string, I assume, I need to first
release the memory inside my C++ method and then allocate a new string
to be returned to the script.

What should I be using to work with memory? alloc/free or can I use
C++ new/delete operators?

With the C or C++ memory allocation allow Ruby script to properly
garbage collect the memory, or should I be using some other SWIG
memory allocation APIs?

--
Kind Regards,
Rajinder Yadav

http://devmentor.org
Do Good! ~ Share Freely

------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Swig-user mailing list
Swig-user@...
https://lists.sourceforge.net/lists/listinfo/swig-user

Re: Working with strings, memory allocation and GC

by Rajinder Yadav-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello all, this is in regards to Ruby & SWIG
Bumping this up as it's got no reply in the last week.


Rajinder Yadav wrote:

> I understand that strings are suppose to be treated as immutable.
> However if I want to mutate the string, I assume, I need to first
> release the memory inside my C++ method and then allocate a new string
> to be returned to the script.
>
> What should I be using to work with memory? malloc/free or can I use
> C++ new/delete operators?
>
> Will the C or C++ memory allocation allow Ruby script to properly
> garbage collect the memory, or should I be using some other SWIG
> memory allocation APIs?
>


--
Kind Regards,
Rajinder Yadav

http://DevMentor.org
Do Good ~ Share Freely

------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Swig-user mailing list
Swig-user@...
https://lists.sourceforge.net/lists/listinfo/swig-user