dumb question (initialize-release)

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

dumb question (initialize-release)

Vincent Lesbros-2
Hi,

this perhaps a stupid question, but, very basic :

When I define a class, subclass of Object,
define an initialize method,
redefine the new message to call the initialize,

and
define a release method.

If I create an instance, it is initialized, well.
but if I cut all the links to this instance and I call the garbage collector,
I thought that the "release" method will be called.
But, the release method is not called.

Is this normal ?
When the release message is sent ?

CF. Code in attachement.

_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc

TestObject.st (1K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: dumb question (initialize-release)

davidbuck
The "release" method isn't called on garbage collection. It's intended to be called manually by your application when an object is no longer needed in order to free the resources that object has acquired.  If you're writing GUI code, release may be called by the windowing code before the window closes.

If you want special code to run when an object if an object is garbage collected, you need to look into finalization. For that, you need WeakArrays or WeakDictionaries.  Check the application programmers guide for details.

David Buck

Vincent Lesbros wrote:
Hi,

this perhaps a stupid question, but, very basic :

When I define a class, subclass of Object,
define an initialize method,
redefine the new message to call the initialize,

and
define a release method.

If I create an instance, it is initialized, well.
but if I cut all the links to this instance and I call the garbage collector,
I thought that the "release" method will be called.
But, the release method is not called.

Is this normal ?
When the release message is sent ?

CF. Code in attachement.
  

_______________________________________________ vwnc mailing list [hidden email] http://lists.cs.uiuc.edu/mailman/listinfo/vwnc

----- No virus found in this message. Checked by AVG - www.avg.com Version: 2013.0.2904 / Virus Database: 2641/6215 - Release Date: 03/30/13 Internal Virus Database is out of date.


_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
Reply | Threaded
Open this post in threaded view
|

Re: dumb question (initialize-release)

Maarten Mostert-2
Good point

But who ever understood something from WeakArrays or WeakDictionaries from the documentation?

@+Maarten


Le 28 avr. 2013 à 17:43, David Buck <[hidden email]> a écrit :

The "release" method isn't called on garbage collection. It's intended to be called manually by your application when an object is no longer needed in order to free the resources that object has acquired.  If you're writing GUI code, release may be called by the windowing code before the window closes.

If you want special code to run when an object if an object is garbage collected, you need to look into finalization. For that, you need WeakArrays or WeakDictionaries.  Check the application programmers guide for details.

David Buck

Vincent Lesbros wrote:
Hi,

this perhaps a stupid question, but, very basic :

When I define a class, subclass of Object,
define an initialize method,
redefine the new message to call the initialize,

and
define a release method.

If I create an instance, it is initialized, well.
but if I cut all the links to this instance and I call the garbage collector,
I thought that the "release" method will be called.
But, the release method is not called.

Is this normal ?
When the release message is sent ?

CF. Code in attachement.
  

_______________________________________________ vwnc mailing list [hidden email] http://lists.cs.uiuc.edu/mailman/listinfo/vwnc

----- No virus found in this message. Checked by AVG - www.avg.com Version: 2013.0.2904 / Virus Database: 2641/6215 - Release Date: 03/30/13 Internal Virus Database is out of date.

_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc


_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
Reply | Threaded
Open this post in threaded view
|

Re: dumb question (initialize-release)

Mark Roberts
Two small points:

1) "...and I call the garbage collector...". As a rule, garbage collection is automatic. In most cases, your application does not need to invoke it. As for #release, David has given the short and sweet answer. You can find a longer discussion here: http://forum.world.st/Method-release-Intention-and-Sender-td2067834.html

2) "But who ever understood something from WeakArrays or WeakDictionaries from the documentation?" There is a ten-page discussion of weak references in the Application Developer's Guide (chapter 19). If you find it wanting, and if you have clear and focused suggestions for improving it, we would be happy to hear them.

Regards,

M. Roberts
Cincom Systems, Inc.

On 4/29/2013 6:01 AM, Maarten Mostert wrote:
Good point

But who ever understood something from WeakArrays or WeakDictionaries from the documentation?

@+Maarten


Le 28 avr. 2013 à 17:43, David Buck <[hidden email]> a écrit :

The "release" method isn't called on garbage collection. It's intended to be called manually by your application when an object is no longer needed in order to free the resources that object has acquired.  If you're writing GUI code, release may be called by the windowing code before the window closes.

If you want special code to run when an object if an object is garbage collected, you need to look into finalization. For that, you need WeakArrays or WeakDictionaries.  Check the application programmers guide for details.

David Buck

Vincent Lesbros wrote:
Hi,

this perhaps a stupid question, but, very basic :

When I define a class, subclass of Object,
define an initialize method,
redefine the new message to call the initialize,

and
define a release method.

If I create an instance, it is initialized, well.
but if I cut all the links to this instance and I call the garbage collector,
I thought that the "release" method will be called.
But, the release method is not called.

Is this normal ?
When the release message is sent ?

CF. Code in attachement.
  

_______________________________________________ vwnc mailing list [hidden email] http://lists.cs.uiuc.edu/mailman/listinfo/vwnc

----- No virus found in this message. Checked by AVG - www.avg.com Version: 2013.0.2904 / Virus Database: 2641/6215 - Release Date: 03/30/13 Internal Virus Database is out of date.

_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc



_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
Reply | Threaded
Open this post in threaded view
|

Re: dumb question (initialize-release)

Boris Popov, DeepCove Labs (SNN)
In reply to this post by Maarten Mostert-2

There’s a handy package in public repository called Weaklings (and WeaklingsTests) just for this type of thing,

 

testMourn

                | before strong offspring |

                before := Core.Object.WeaklingsRegistry size.

                strong := String withAll: 'Hello'.

                strong mourn: [:dying | offspring := dying copy].

                self assert: offspring isNil.

                strong := 'World'.

                ObjectMemory globalGarbageCollect.

                self assert: before = Core.Object.WeaklingsRegistry size.

                self assert: offspring = 'Hello'.

 

-Boris

 

From: [hidden email] [mailto:[hidden email]] On Behalf Of Mark D. Roberts
Sent: Monday, April 29, 2013 4:55 AM
To: [hidden email]
Subject: Re: [vwnc] dumb question (initialize-release)

 

Two small points:

1) "...and I call the garbage collector...". As a rule, garbage collection is automatic. In most cases, your application does not need to invoke it. As for #release, David has given the short and sweet answer. You can find a longer discussion here: http://forum.world.st/Method-release-Intention-and-Sender-td2067834.html

2) "But who ever understood something from WeakArrays or WeakDictionaries from the documentation?" There is a ten-page discussion of weak references in the Application Developer's Guide (chapter 19). If you find it wanting, and if you have clear and focused suggestions for improving it, we would be happy to hear them.

Regards,

M. Roberts
Cincom Systems, Inc.

On 4/29/2013 6:01 AM, Maarten Mostert wrote:

Good point

 

But who ever understood something from WeakArrays or WeakDictionaries from the documentation?

 

@+Maarten

 

 

Le 28 avr. 2013 à 17:43, David Buck <[hidden email]> a écrit :



The "release" method isn't called on garbage collection. It's intended to be called manually by your application when an object is no longer needed in order to free the resources that object has acquired.  If you're writing GUI code, release may be called by the windowing code before the window closes.

If you want special code to run when an object if an object is garbage collected, you need to look into finalization. For that, you need WeakArrays or WeakDictionaries.  Check the application programmers guide for details.

David Buck

Vincent Lesbros wrote:

Hi,
 
this perhaps a stupid question, but, very basic :
 
When I define a class, subclass of Object,
define an initialize method,
redefine the new message to call the initialize,
 
and
define a release method.
 
If I create an instance, it is initialized, well.
but if I cut all the links to this instance and I call the garbage collector,
I thought that the "release" method will be called.
But, the release method is not called.
 
Is this normal ?
When the release message is sent ?
 
CF. Code in attachement.
  

 
_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
  

 
-----
No virus found in this message.
Checked by AVG - www.avg.com
Version: 2013.0.2904 / Virus Database: 2641/6215 - Release Date: 03/30/13
Internal Virus Database is out of date.
  

 

_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc

 

 


_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
Reply | Threaded
Open this post in threaded view
|

Re: dumb question (initialize-release)

Maarten Mostert
In reply to this post by Mark Roberts

Welll yes I am still far away from this level of abstraction, but thanks for the extra info, ..

I am printing High resoltion PDF files for which I don't manage to release, so sooner or later I'll have to bite this ...

 

@+Maarten,

 

 

 

> "Mark D. Roberts" <[hidden email]> |

Two small points:

1) "...and I call the garbage collector...". As a rule, garbage collection is automatic. In most cases, your application does not need to invoke it. As for #release, David has given the short and sweet answer. You can find a longer discussion here: http://forum.world.st/Method-release-Intention-and-Sender-td2067834.html

2) "But who ever understood something from WeakArrays or WeakDictionaries from the documentation?" There is a ten-page discussion of weak references in the Application Developer's Guide (chapter 19). If you find it wanting, and if you have clear and focused suggestions for improving it, we would be happy to hear them.

Regards,

M. Roberts
Cincom Systems, Inc.

On 4/29/2013 6:01 AM, Maarten Mostert wrote:
Good point
But who ever understood something from WeakArrays or WeakDictionaries from the documentation?
@+Maarten

Le 28 avr. 2013 à 17:43, David Buck <[hidden email]> a écrit :

The "release" method isn't called on garbage collection. It's intended to be called manually by your application when an object is no longer needed in order to free the resources that object has acquired.  If you're writing GUI code, release may be called by the windowing code before the window closes.

If you want special code to run when an object if an object is garbage collected, you need to look into finalization. For that, you need WeakArrays or WeakDictionaries.  Check the application programmers guide for details.

David Buck

Vincent Lesbros wrote:

Hi, this perhaps a stupid question, but, very basic : When I define a class, subclass of Object, define an initialize method, redefine the new message to call the initialize, and define a release method. If I create an instance, it is initialized, well. but if I cut all the links to this instance and I call the garbage collector, I thought that the "release" method will be called. But, the release method is not called. Is this normal ? When the release message is sent ? CF. Code in attachement.


_______________________________________________ vwnc mailing list [hidden email] http://lists.cs.uiuc.edu/mailman/listinfo/vwnc


----- No virus found in this message. Checked by AVG - www.avg.com Version: 2013.0.2904 / Virus Database: 2641/6215 - Release Date: 03/30/13 Internal Virus Database is out of date.
_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc

_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc