You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
SDL_Init sets up event handlers which SQL_Quit does not release, which prevents GC of the Module instance #6172
From what I see, the problem is in the following line:
SDL_Init(SDL_INIT_VIDEO);
This line is situated in the class method exposed to the JavaScript and, although the method is never called, it somehow prevents Module instance from being destroyed and releasing its memory. When the line is commented out, everything is garbage collected properly and memory is released.
Is there any solution or workaround for this problem?
changed the title [-]Unable to release memory from the Module instance[/-][+]SDL_Init sets up event handlers which SQL_Quit does not release, which prevents GC of the Module instance [/+]on Feb 1, 2018
Try checking browser's DOM Inspector tool to see which event handlers are still active, and see where they are registered, to get a possible clue where they should get unregistered in turn.
For me they all work in exactly the same way as with SDL_Init.
All these commands though create the same event listeners: gamepadconnected and gamepaddisconnected. When I delete those listeners manually from DevTools, memory is released correctly, so your theory seems to be true.
This issue has been automatically marked as stale because there has been no activity in the past year. It will be closed automatically if no further activity occurs in the next 7 days. Feel free to re-open at any time if this issue is still relevant.
Activity
kripken commentedon Feb 1, 2018
Thanks for the testcase (I had to lower the amount of memory to 128MB or my browser wouldn't load it, but otherwise it all works as described).
I believe what's going on is that
SDL_Initsets up some event listeners, and they keep everything else alive.In principle calling
SDL_Quitshould remove those. However, it looks like we don't do that, which is a bug. I'll rename this issue to focus on that.[-]Unable to release memory from the Module instance[/-][+]SDL_Init sets up event handlers which SQL_Quit does not release, which prevents GC of the Module instance [/+]juj commentedon Feb 1, 2018
Try checking browser's DOM Inspector tool to see which event handlers are still active, and see where they are registered, to get a possible clue where they should get unregistered in turn.
dmitrykuzmin commentedon Feb 2, 2018
Update: I've found some more SDL commands that prevent Module instance from being garbage collected in the same way as
SDL_Initdoes.They are as follows:
SDL_CreateWindow,SDL_PollEventand evenSDL_Quititself.Maybe there are more, but those are the ones I use in my program.
I updated my test case with branches for each failing command:
SDL_CreateWindow, SDL_PollEvent, SDL_Quit.
For me they all work in exactly the same way as with
SDL_Init.All these commands though create the same event listeners:
gamepadconnectedandgamepaddisconnected. When I delete those listeners manually from DevTools, memory is released correctly, so your theory seems to be true.remove gamepad event handlers after running
stale commentedon Sep 19, 2019
This issue has been automatically marked as stale because there has been no activity in the past year. It will be closed automatically if no further activity occurs in the next 7 days. Feel free to re-open at any time if this issue is still relevant.
ongamex commentedon Oct 24, 2019
Well something similar looking, but that thing is now an error:
Calling stub instead of sigaction() sge_game.html:1246:19
printErr http://localhost:8080/sge_game.html:1246
_sigaction http://localhost:8080/sge_game.js:12084
_SDL_QuitInit http://localhost:8080/sge_game.js:308720
_SDL_EventsInit http://localhost:8080/sge_game.js:305899
_SDL_InitSubSystem http://localhost:8080/sge_game.js:300381
_SDL_Init http://localhost:8080/sge_game.js:300575
_main http://localhost:8080/sge_game.js:86826
_main http://localhost:8080/sge_game.js:513764
callMain http://localhost:8080/sge_game.js:514116
doRun http://localhost:8080/sge_game.js:514175
run http://localhost:8080/sge_game.js:514186
sbc100 commentedon Oct 25, 2019
Are you building with USE_SDL=2? It looks like it because SDL_InitSubSystem does nothing in emscirpten normally. Might be worth filing a bug at https://github.com/emscripten-ports/SDL2? In any case this doesn't look related to this bug.