Skip to content
This repository has been archived by the owner on May 8, 2024. It is now read-only.

Weak Event Emitter #14

Open
Dinhero21 opened this issue Dec 19, 2023 · 0 comments
Open

Weak Event Emitter #14

Dinhero21 opened this issue Dec 19, 2023 · 0 comments

Comments

@Dinhero21
Copy link
Owner

Dinhero21 commented Dec 19, 2023

This probably shouldn't be an issue but I'm just creating this for means of documentation.

The way IO Events are handled (more specifically the Mouse Prioritization System) uses a wacky EventFrame system that requires you to call free() when you don't need the object anymore.

Of course, this is very error-prone as memory leaks can easily be created by simply forgetting to call free() which should be the garbage collector's job anyway!

So, the idea is to create an alternative to EventTargets / node:events that uses WeakMaps (or WeakRef Maps for iteratability) that wouldn't keep strong references that would make it automatically garbage-collectable.

(this might be best made into its own standalone package, weak-events anyon- oh wait that's already taken)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant