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
[Solved ?] Memory leak when updating gamepad detection during Runtime #78
In order to update gamepad detection during runtime (as Jinput doesn't), I created a "class patch" to periodicaly nullify registered controllers in DefaultControllerEnvironment class, using reflection.
The code is quite effecive : if I unplug - replug the gamepad, the game correctly detect it !
Problem is, the more time is spent during runtime, the bigger the gap between an "actual gamepad input" and its detection, is... After 2 minutes, it's barely playable ... After 4, the game just doesn't respond to any gamepad input.
As said, the "patch" is quite good at its job ! And would be perfect without this problem... Any suggestion ?
I also wrote a hacky solution for detecting new controllers, using a different method. I'm not sure, but maybe this works without the memory leak that you're running into?
I also wrote a hacky solution for detecting new controllers, using a different method. I'm not sure, but maybe this works without the memory leak that you're running into?
Ty ! I'll give a close look, try it, and give feedback soon :)
I also wrote a hacky solution for detecting new controllers, using a different method. I'm not sure, but maybe this works without the memory leak that you're running into?
I just tried your "hack", pour over your code to understand what you were doing, slightly adujst it to works with my system, etc.
You did a pretty job there ! It works perfectly ! It's even easier to use that what i was doing.
To clarify for people reading this and willing to have a clarification on what our codes are about :
ControllerEnvironment.getDefaultEnvironment() -> "Env"
Mine was "hacking" Env to reset some fields, which cause memory leaks (didn't figure out why, but probably a hidden list filling slowly with more and more new values)
his just hacks Env itself to destroy the object, forcing Jinput to rebuild it, which probably destroy the "hidden list causing memory leak"
changed the title [-]Memory leak when updating gamepad detection during Runtime[/-][+]|Solved] Memory leak when updating gamepad detection during Runtime[/+]on Oct 25, 2023
changed the title [-]|Solved] Memory leak when updating gamepad detection during Runtime[/-][+][Solved] Memory leak when updating gamepad detection during Runtime[/+]on Oct 25, 2023
Looks like there is some momentum behind this version, good to see.
The reason for the RawInputEventQueue creating a thread is that direct input (at least on some older version of windows/directx?) required using the same thread to read the data as opened the device, otherwise no data was being read. It could be modified to only create that thread in certain circumstances...
Linux has a similar issue with the event devices needing a single thread if memory serves.
Someone just found a memory leak in my solution as well. Currently working on a fix
Ho... well, i didn't noticed it because mine was visible after 5~10 minutes, as yours is 'only' visible after 40 minutes i didn't see it. I'll give a look on the topic and study the problem... I've no doubt we will eventually find a solution :)
changed the title [-][Solved] Memory leak when updating gamepad detection during Runtime[/-][+][Solved ?] Memory leak when updating gamepad detection during Runtime[/+]on Oct 25, 2023
Activity
Valkryst commentedon Oct 24, 2023
I also wrote a hacky solution for detecting new controllers, using a different method. I'm not sure, but maybe this works without the memory leak that you're running into?
sunsigne commentedon Oct 25, 2023
Ty ! I'll give a close look, try it, and give feedback soon :)
sunsigne commentedon Oct 25, 2023
I just tried your "hack", pour over your code to understand what you were doing, slightly adujst it to works with my system, etc.
You did a pretty job there ! It works perfectly ! It's even easier to use that what i was doing.
To clarify for people reading this and willing to have a clarification on what our codes are about :
ControllerEnvironment.getDefaultEnvironment() -> "Env"
[-]Memory leak when updating gamepad detection during Runtime[/-][+]|Solved] Memory leak when updating gamepad detection during Runtime[/+][-]|Solved] Memory leak when updating gamepad detection during Runtime[/-][+][Solved] Memory leak when updating gamepad detection during Runtime[/+]Valkryst commentedon Oct 25, 2023
@sunsigne
Someone just found a memory leak in my solution as well. Currently working on a fix
Endolf commentedon Oct 25, 2023
Looks like there is some momentum behind this version, good to see.
The reason for the RawInputEventQueue creating a thread is that direct input (at least on some older version of windows/directx?) required using the same thread to read the data as opened the device, otherwise no data was being read. It could be modified to only create that thread in certain circumstances...
Linux has a similar issue with the event devices needing a single thread if memory serves.
sunsigne commentedon Oct 25, 2023
Ho... well, i didn't noticed it because mine was visible after 5~10 minutes, as yours is 'only' visible after 40 minutes i didn't see it. I'll give a look on the topic and study the problem... I've no doubt we will eventually find a solution :)
[-][Solved] Memory leak when updating gamepad detection during Runtime[/-][+][Solved ?] Memory leak when updating gamepad detection during Runtime[/+]