[JAVA-817] PermGen memory leak. A deamon thread "CursorCleanerThread" doesn't stopped when undeploy a web application. Created: 27/Apr/13  Updated: 25/Jun/13  Resolved: 27/Apr/13

Status: Closed
Project: Java Driver
Component/s: Monitoring
Affects Version/s: 2.11.1
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: wpc Assignee: Unassigned
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Windows 7 with sp1
Tomcat 7



 Description   

a thread named "MongoCleanerXXX" still at sleep state when a web application is undeployed.
This cause a PermGen memory leak.

The close method in Mongo try to interrupt the cleaner thread. But, that doesn't work.
There's a try-catch block in the run() of CursorCleanerThread, it catch any Throwable, So, the interrupt may not let the thread die.



 Comments   
Comment by Jeffrey Yemin [ 27/Apr/13 ]

It does work, because _connector.isOpen() will be false, and the loop will exit.

        public void run() {
            while (_connector.isOpen()) {
                try {
                    try {
                        Thread.sleep(cleanerIntervalMS);
                    } catch (InterruptedException e) {
                        //caused by the Mongo instance being closed -- proceed with cleanup
                    }
                    for (DB db : _dbs.values()) {
                        db.cleanCursors(true);
                    }
                } catch (Throwable t) {
                    // thread must never die
                }
            }
        }
    }

but you have to make sure that you call Mongo#close.

Generated at Thu Feb 08 08:53:08 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.