Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Garbage collection #584

Closed
boxerab opened this issue May 4, 2024 · 5 comments
Closed

Garbage collection #584

boxerab opened this issue May 4, 2024 · 5 comments
Labels
question Further information is requested

Comments

@boxerab
Copy link
Contributor

boxerab commented May 4, 2024

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.

@tsung-wei-huang
Copy link
Member

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.

@tsung-wei-huang tsung-wei-huang added the question Further information is requested label May 6, 2024
@boxerab
Copy link
Contributor Author

boxerab commented May 6, 2024

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.

@boxerab
Copy link
Contributor Author

boxerab commented May 11, 2024

@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.

@boxerab
Copy link
Contributor Author

boxerab commented May 12, 2024

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

@boxerab
Copy link
Contributor Author

boxerab commented May 12, 2024

Closed

@boxerab boxerab closed this as completed May 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants