Mantis Bugtracker
  

Viewing Issue Simple Details Jump to Notes ] View Advanced ] Issue History ] Print ]
ID Category Severity Reproducibility Date Submitted Last Update
0003692 [Squeak] FFI feature N/A 05-21-06 22:24 07-14-06 15:06
Reporter nicolas cellier View Status public  
Assigned To andreas
Priority normal Resolution fixed  
Status closed   Product Version 3.9
Summary 0003692: [FFI][NEW FEATURE] ExternalAdress auto-free
Description when ExternalAddress class>>allocate: is used, care must be taken to invoke ExternalAddress>>free to release external heap memory.
This is not easy and involves a lot of ensure: guards...

An alternative is to use a weak registry.

ExternalAddress gcallocate: use ExternalAddress finalizationRegistry, that is Object finalizationRegistry by default, but maybe a specific registry in ExternalAddress would be a good idea (not implemented).

Executor is a clone of the address, as provided by default in object.

Beware: never invoke free directly on a gcallocated ExternalAddress (no guard in this implementation).
Additional Information
Attached Files  FFI-ExternalAddress-autoFree-Feature.1.cs [^] (1,422 bytes) 05-21-06 22:26

- Relationships

- Notes
(0005025 - 167 - 167 - 167 - 167 - 167 - 167)
andreas
05-21-06 23:54

This looks very useful, thanks. One question though: Why did you have to reimplement shallowCopy? Shouldn't the implementation in Object (using a primitive) be enough?
 
(0005026 - 384 - 426 - 426 - 426 - 426 - 426)
nicolas cellier
05-22-06 13:13

Yes, super shallowCopy should do the work.
Unfortunately, in my 3.9a, it calls new: instead of basicNew:, and that fails because ExternalAddress new: raise an error.

I think Object>>shallowCopy should use basicNew basicNew: basicAt: basicAt:put: instVarAt: instVarAt:put: and nothing else (better if in a primitive).

Implementing ExternalAddress>>shallowCopy is a workaround...
 
(0005030 - 429 - 477 - 477 - 477 - 477 - 477)
nicolas cellier
05-22-06 22:24

I did not have an image when writing last note.
Object>>shallowCopy is just fine.

super shallowCopy is not in Object, it is Sequenceable>>shallowCopy
that is defined as copyFrom:to:, that will call new:

Implementing shallowCopy there will avoid implementing postCopy for some collection, but it also make the shallowCopy not shallow (example Text new shallowCopy does not share string nor runs). Is it really a good idea?
 
(0005033 - 65 - 65 - 217 - 217 - 217 - 217)
andreas
05-23-06 22:18

Integrated in http://source.squeakfoundation.org/FFI/FFI-ar.9.mcz [^]
 
(0005895 - 7 - 7 - 7 - 7 - 7 - 7)
MarcusDenker
07-14-06 15:06

in 70XX
 

- Issue History
Date Modified Username Field Change
05-21-06 22:24 nicolas cellier New Issue
05-21-06 22:24 nicolas cellier Status new => assigned
05-21-06 22:24 nicolas cellier Assigned To  => andreas
05-21-06 22:26 nicolas cellier File Added: FFI-ExternalAddress-autoFree-Feature.1.cs
05-21-06 23:54 andreas Note Added: 0005025
05-22-06 13:13 nicolas cellier Note Added: 0005026
05-22-06 22:24 nicolas cellier Note Added: 0005030
05-23-06 22:18 andreas Status assigned => resolved
05-23-06 22:18 andreas Resolution open => fixed
05-23-06 22:18 andreas Note Added: 0005033
07-14-06 15:06 MarcusDenker Status resolved => closed
07-14-06 15:06 MarcusDenker Note Added: 0005895
07-14-06 15:06 MarcusDenker Fixed in Version  => 3.9


Mantis 1.0.8[^]
Copyright © 2000 - 2007 Mantis Group
57 total queries executed.
40 unique queries executed.
Powered by Mantis Bugtracker