From: Ryan P. <rp...@gm...> - 2013-12-06 21:24:40
|
I am sure I'm doing something silly here, but this won't call the finalizer until the thread is done (or at least it correlates strongly...). Currently x86_64 1.1.12: https://gist.github.com/rpav/7832108 Snippet: (defclass finalize-test () ()) (defun make-my-thread () (bt:make-thread (lambda () (sleep 300)))) (defmethod initialize-instance ((instance finalize-test) &key &allow-other-keys) (make-my-thread) (tg:finalize instance (lambda () (format t "I am all done.~%")))) (make-instance 'finalize-test) (cl-user::gc :full t) Calling GC repeatedly doesn't seem to do anything until I kill the thread or wait for it to end. -- Ryan Pavlik <rp...@gm...> | https://github.com/rpav 425.220.9585 |
From: Stas B. <sta...@gm...> - 2013-12-08 07:42:56
|
Ryan Pavlik <rp...@gm...> writes: > I am sure I'm doing something silly here, but this won't call the finalizer > until the thread is done (or at least it correlates strongly...). > Currently x86_64 1.1.12: > > https://gist.github.com/rpav/7832108 There are two possible causes: * Something that looks like a pointer is present on the stack * Something is pinned down to be passed to C Both of those situations will tell the GC not to move that pointer, in the first case, to avoid falsely collecting a live object, and in the second case, to allow C to work with an object without worrying that it has moved. And the first case is what makes the GC conservative. What is unfortunate is that this mechanism is page-granular, i.e., to pin down a pointer, the whole page where it resides is pinned down. And if the pages includes some other data, it won't be collected either. -- With best regards, Stas. |