[squeak-dev] Re: ExternalAddress and block copy; ByteArray and external calls?

Andreas Raab andreas.raab at gmx.de
Mon Aug 23 20:33:04 UTC 2010


On 8/23/2010 12:46 PM, Schwab,Wilhelm K wrote:
> Are there any well-worn ways to move data into and out of external memory?

You mean like:

memcpyTo: destAddr from: srcAddr length: sz
	<cdecl: long 'memcpy' (void* void* ulong) module: 'libc.so'>
	^self externalCallFailed

Or am I missing something?

> The best I have been able to uncover are recommendations to either do it one byte at a time (yuk!) or to via bitblt.  Those posts come from several years ago, and include mention that ExternalAddress does not clean up after itself.  Looking in Pharo now, I see #finalize that calls free; have things move along to avoid memory leaks?
>
> There are no conditions in #finalize or #free, which raises questions about whether it is safe to send #free to quickly free memory that will no longer be used?  In Dolphin, I reflexively free ODBC related handles because they quickly pile up and cause problems despite the finalization "water mark."  I am currently working with a data acquisition board and will be needing memory for clearly defined periods.  I also need to get data out of the buffers, which sent me looking for an official way to do so.
>
> To what extent, if any, can String and ByteArray be used as buffers for external calls?  Dolphin made that robust, but there were hints that the gc was slightly tamed to allow it.  The little reading I have done in squeak-dev archives suggests that squeak/pharo is not so forgiving.  Is that true?  Is there a way to request a byte array allocated in a fixed (or whatever the jargon is) heap so that external calls will be safe?
>
> Bill
>
>
>




More information about the Squeak-dev mailing list