taskflow / taskflow

A General-purpose Parallel and Heterogeneous Task Programming System

Home Page:https://taskflow.github.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Garbage collection

boxerab opened this issue · comments

Does the library know, or can it cheaply determine, if a completed task has no more dependencies in the graph ?
If so, the library could call a designated cleanup method, that could clean up memory and other resources.

Currently, we don't have this feature. However, we do have an object pool to recycle destroyed tasks so we don't need too many expensive malloc calls when allocating task storage.

Thanks. I'm interested in a higher level recycle -returning a buffer owned by my task to a buffer pool.
I will look into implementing this. It looks like a task's num_successors method could be used to determine if it is safe to call a custom cleanup method on the task.

@tsung-wei-huang I've implemented this using an Observer - when I create tasks I add to std::map with tf::Task hash as key and my custom object as value, and call free on object in the Observer's on_exit method, via hash lookup, and when the task has no successors. It would be more efficient for me if I could store a void* pointer in the Task's Node, and then retrieve in on_exit; then I wouldn't need a map. Would you consider adding this ? Otherwise there is no built-in way of associating a tf::Task with a user object.

Well, it turns out I can manage memory myself using reference counting, so no need for garbage collection

Closed