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

[runtime] Possible Broacaster leaks #528

Closed
jfarcand opened this issue Jul 25, 2012 · 1 comment
Closed

[runtime] Possible Broacaster leaks #528

jfarcand opened this issue Jul 25, 2012 · 1 comment
Labels

Comments

@jfarcand
Copy link
Member

From this thread

Hi,
Regarding the memory leak, in the class DefaultBroadcasterFactory

    @Override
    public Broadcaster lookup(Class<? extends Broadcaster> c, Object id, boolean createIfNull) {
        Broadcaster b = store.get(id);
        if (b != null && !c.isAssignableFrom(b.getClass())) {
            String msg = "Invalid lookup class " + c.getName() + ". Cached class is: " + b.getClass().getName();
            logger.debug(msg);
            throw new IllegalStateException(msg);
        }
        if ((b == null && createIfNull) || (b != null && b.isDestroyed())) {
            if (b != null) {
                logger.debug("Removing destroyed Broadcaster {}", b.getID());
                store.remove(b.getID(), b);
            }
            if (store.putIfAbsent(id, createBroadcaster(c, id)) == null) {
                logger.debug("Added Broadcaster {} . Factory size: {}", id, store.size());
            }
            b = store.get(id);
        }
        return b;
    }

broadcasters are created and added to the store, but if they already located in the store under the same ID, threads are created and not added to the store, so when you destroy the factory you just terminate broadcasters in the store and the others (created by the testWebapp2) still alive, thus, the memory leak.

@jfarcand
Copy link
Member Author

jfarcand commented Nov 6, 2012

Fixed

@jfarcand jfarcand closed this as completed Nov 6, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant