altv-js-module
altv-js-module copied to clipboard
Client side memory leak
Description of the problem
Reproduction steps
Reproduction steps
-
Check heap size in console
-
reconnect
-
Check heap size in console again
Expected behaviour
No memory leak!!
Additional context
No response
Operating system
Windows 11
Version
dev/10.0-dev12
Scope
client
It's nothing new that Client JS is full of memory leaks and unfortunately they are very hard to track down
Step 2. Reconnect
Well there's your problem.
Step 2. Reconnect
Well there's your problem.
@Stuyk what do you mean?
alt:V was never written with the intention of cleanup after reconnect. Yes it's a nice to have thing but there are certain things which cannot be cleaned up during the reconnection process. The code was written to be most performant during a single connection and a game reboot would be required to get that same performance on other servers.
Its not about cleanup, its a memory leak in js module, that can be fixed (and yes, Leon already has replied that this is not an easy fix).
And yes I know that reconnect (resource restart) is only for development (ofc you cant use it without debug mode xd)
Fix of this issue can improve js development experience on alt:V, nothing more
if you have gamemode that eats 100mb of the heap on first resource start and if you do 10-20 reconnects (resource restarts) your game will freeze on each resource start every reconnect for 5 or more seconds because of the heap overflow
I also noticed this when I tested my server, GTA even crashed :(
For an "easy" fix we could maybe just "restart" the script runtime on reconnect, so that it creates a new isolate on every reconnect. This would definitely fix all memory leaks (at least those originating from JS objects... xd) but I don't know whether that will fuck other shit up
and if this fix turns out to be possible, resource restart will be overboard?
I just pushed 6074731e06e7a6e7ba03e69c2fa873841ec86976 which should definitely fix some memory leaks that existed before, someone can benchmark it to find out whether this improved anything
i saw that, if u connect to the same server but without resources, it takes time to load resource but there no resources. if u connect server, turn off server, turn on server without resources, reconnect to the server, it's need time to load resources that not exists, maybe there is memory leak, because old resource still in memory