Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Excessive use of user objects on Windows #28

Closed
breiler opened this issue Feb 29, 2024 · 2 comments · Fixed by #29
Closed

Excessive use of user objects on Windows #28

breiler opened this issue Feb 29, 2024 · 2 comments · Fixed by #29

Comments

@breiler
Copy link

breiler commented Feb 29, 2024

When using the library (version 2.26.5.0, 2.26.4.0 and 2.0.20.0) on Windows it seems that it will start allocating "User Objects" which will finally make the application unresponsive. On Mac and Linux this works without problems.

The interesting thing is that if the window of the related process is not in focus it will not create new user objects even though the example is a console application:

2024-02-29.10-03-52.mp4

Example program:

package com.willwinder.ugs.nbp.joystick;

import com.studiohartman.jamepad.Configuration;
import com.studiohartman.jamepad.ControllerManager;
import com.studiohartman.jamepad.ControllerState;


public class TestMain {
    public static void main(String[] args) {
        Configuration configuration = new Configuration();
        ControllerManager controllerManager = new ControllerManager(configuration, "/com/willwinder/ugs/nbp/joystick/gamecontrollerdb.txt");
        controllerManager.initSDLGamepad();
        
        // Print a message when the "A" button is pressed. Exit if the "B" button is pressed
        // or the controller disconnects.
        while (true) {
            ControllerState currState = controllerManager.getState(0);

            if (!currState.isConnected || currState.b) {
                break;
            }
            if (currState.a) {
                System.out.println("\"A\" on \"" + currState.controllerType + "\" is pressed");
            }
        }
    }
}

Tried with JDK Temurin 17.0.9 and Temuring 21.0.2.

@breiler
Copy link
Author

breiler commented Mar 5, 2024

I built this locally and upgraded SDL to the latest release https://github.com/libsdl-org/SDL/tree/release-2.30.x and problem was no longer present.

@breiler
Copy link
Author

breiler commented Mar 5, 2024

Tried it on Linux x64, Windows x64 and MacOSX using the new dependency and at least the small test program works as before:

<dependency>
  <artifactId>jamepad</artifactId>
  <groupId>com.badlogicgames.jamepad</groupId>
  <version>2.30.0.0-SNAPSHOT</version>
</dependency>

The problem with user objects are no longer present:
https://github.com/libgdx/Jamepad/assets/8962024/953b1281-b984-48d0-8475-4c8f6b83f3f1

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

Successfully merging a pull request may close this issue.

1 participant