Application and Events

Does anyone know if Foundry's Application (or the browser itself) does anything magical to clean up after events registered on the html elements created by that application? I've a vague memory that this is one of the things jquery was good for, and that unless you explicitly clean up manually registered events, you've got potential for a memory leak. I don't have any good sources for that and I'm pretty fuzzy on browser memory and performance matters, but I wondered if anyone more knowledgable than me has taken a look at such things.
C
Calego544d ago
🧵
UU
Unknown User544d ago
C
Calego544d ago
there's not like some element.unregisterAllListners ?
UU
Unknown User544d ago
C
Calego544d ago
Alright next question, I've done some reading about garbage collection in the browser and the thing that stuck with me is something to the effect of:
The memory of the element can't be cleaned up because there's still an event listener registered to it
Full disclosure, i have about 5% confidence in that memory So the browser is smart enough to know that when an element is nuked via replacing innerHtml, its old event listeners are useless and thus can be nuked as well?
UU
Unknown User544d ago
C
Calego544d ago
hypothesis: it would only be noticable if the events were registered without jquery because, to my limited understanding, that's one of jquery's claims to fame
UU
Unknown User544d ago
C
Calego544d ago
i'm failing pretty hard at googling this...
UU
Unknown User544d ago
C
Calego544d ago
I tried this a long time ago and what I saw concerned me, but I realized I had no real knowledge of what I was looking at and wasn't feeling frisky that week 😛
UU
Unknown User544d ago
C
Calego544d ago
So it sounds like... 1. element created 2. events are registered on that element 3. time passes 4. innerHtml change causes old element to be destroyed 5. old element being destroyed destroys event listeners on said element 6. event listeners being destroyed means that the callbacks are no longer referenced Therefore... everything is garbage collectable. 7. repeat from 1.
UU
Unknown User544d ago
C
Calego544d ago
The whole "no references to those elements" is what trips me up. Because sometimes I necessarily have a reference to that element in my event handler callback... So like... I do still have a reference there, but it's kinda circular? maybe some day i'll learn more about profiling and do that experiment again ¯\_(ツ)_/¯
UU
Unknown User544d ago
C
Calego544d ago
interesting
UU
Unknown User544d ago
C
Calego544d ago
thanks @ghost 🙂
LTL
Leo The League Lion544d ago
@calego gave vote LeaguePoints™ to @ghost (#4 • 634)
UU
Unknown User544d ago
C
Calego544d ago
that feels expensive
UU
Unknown User544d ago
C
Calego544d ago
tfw you just want to have your cake and eat it too
UU
Unknown User544d ago
C
Calego544d ago
makes sense, plus they're probably smart enough to wait until its likely that they can run without disruption very interesting
UU
Unknown User544d ago
C
Calego544d ago
gotchya, thanks that explains why there's not a million 'gotchyas' blog articles talking about this interaction
LTL
Leo The League Lion544d ago
@calego gave vote LeaguePoints™ to @mouse0270 (#27 • 97)
UU
Unknown User544d ago
Want results from more Discord servers?
Add your server
More Posts
PopOut!Just starting a thread here for some discussion of "PopOut!" module in relation to my UI library / TPackage jam judge signup threadPackage jam judge signup thread (free league points inside)git filter troubleshootingI'm troubleshooting a new setup that my code contributors can benefit from. I'm using a .gitconfig fmultiroll damage roll messagesMessing with multiroll chat message in v10❓About Commissions**Do not post commissions in this thread.** This thread is for discussing the commissions process, gIssue Submission ToolI'm looking for suggestions for free ticket submission without signing into GitHub that go beyond BuMM+, manifest+, attributions, and moreWe can make a thread to keep the MM+ discussion seperate if you'd likeGlitterSuppose someone wanted to make a module which created a stylistic ~~defect~~ enhancement that never Here s an example No template data inHere's an example. No template data in the actor object, but the object is associated with a templatRolling Hooks**Rolling Hooks!** I am working on a couple of additions to one of the upcoming version of 5e to addWeight MRSure.2.0.0 explorationFrom Atropos in the mothership (in v10 Feedback) > Hello folks, for those of you testing V10 using tElectron ViteIt loads at least.early v10 compat testing@dnd5e - No action required Work is being done on fixing the core system compatibility with v10 in module.json helpYou have no manifest or download fields.TyphonJS Runtime Library - RC 0.0.12The TyphonJS Runtime Library / TRL release candidate version 0.0.12 is now available. This is a massCypress FunYeah, unfortunately it ain't that simple 😅 Cypress, like you say, automatically retries things, andpreUpdateHook questionHey all, question for anyone who has a sec. I'm trying to use `preCreateActor` to add rolled values spitballing about jest mocksok. ok. ok. pure spitballing theory here. All the client side source exists in esmodule form (hopef1.6.1 testing@dnd5e Testing Action Requested but not required. version 1.6.1 is a bugfix version, it's pretty cl