The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

import-bot (20211) [Avatar] Offline
#1
[Originally posted by wuruoyun]

Dear Jon,

As I am using your package, I found that many addXXX() function do not have a
matching removeXXX(). For example, FeedbackManager has a addTarget(), but no
removeTarget(); AwtMouseButtonSensor has a addEventSource(), but no
removeEventSource().

It is fine if you are writing a small exmple programe. However, in a bigger
program, a 'memory leak' will arise. Say, if I have a list of 3D objects and
new objects can be added while unwanted objects can be removed. To make them
all selectable, they have to be registered with a SelectManager (a sub-class
of FeedbackManager). Once registered, you can't remove these objects from
memory, even you don't want the objects any more.

Is there a good solution for this problem?

Best Wishes!
Ruoyun
import-bot (20211) [Avatar] Offline
#2
Re: Lack of removeXXX() functions leads to 'memory leak'
[Originally posted by author]

You are generally correct in your observation that "removeXxx()" methods are
lacking in the framework. This was an unfortunate expedient in getting the
book out within my lifetime. Note, however, the general purpose classes, such
as the event splitters, do include such methods and many of the classes that
do not allow access to the event target list.

As I mentioned in the book the selection manager portion of the framework
leaves a lot to be desired. The need for explicit remove methods is part of
this.

As a side note, to you and others that are interested in the framework, I'd be
willing to open it to open source if there were sufficient interest in
extending it. As I said in the book, I feel it is a good start but there is
much left to do.

--jon


> Dear Jon,
>
> As I am using your package, I found that many addXXX() function do not have a
> matching removeXXX(). For example, FeedbackManager has a addTarget(), but no
> removeTarget(); AwtMouseButtonSensor has a addEventSource(), but no
> removeEventSource().
>
> It is fine if you are writing a small exmple programe. However, in a bigger
> program, a 'memory leak' will arise. Say, if I have a list of 3D objects and
> new objects can be added while unwanted objects can be removed. To make them
> all selectable, they have to be registered with a SelectManager (a sub-class
> of FeedbackManager). Once registered, you can't remove these objects from
> memory, even you don't want the objects any more.
>
> Is there a good solution for this problem?
>
> Best Wishes!
> Ruoyun