java.lang.OutOfMemoryError

There are no available Samebug tips for this exception. Do you have an idea how to solve this issue? A short tip would help users who saw this issue last week.

  • I run frequent scripts on a node called "utils" using the groovy CLI to communicate with Jenkins. After a couple of hours, the CLI stops working. I've found several java.lang.OutOfMemoryError: unable to create new native thread in the log file. I've checked the memory and it uses 500 mb out of 1.5gb allocated. I searched the net and found that it could be caused by too many threads. I've done a thread dump and found that the node called "utils" has *1074 threads* that look like this: {panel} ComThread for Thread-1022 "ComThread for Thread-1022" Id=1497 Group=main RUNNABLE (in native) at com4j.Win32Lock.suspend0(Native Method) at com4j.Win32Lock.suspend(Win32Lock.java:33) at com4j.ComThread.run0(ComThread.java:135) at com4j.ComThread.run(ComThread.java:125) {panel} Finally, Jenkins crashes with out of memory. Attached is the thread dump. Any ideas? It started around the time when I finally understood how the groovy CLI scripts work and added a few of them. ------------------- The groovy scripts I run are: {noformat} Thread.getAllStackTraces().keySet().each() { item -> if (item.getName().contains("SCM polling") && item.getName().contains("waiting for hudson.remoting")) { println "Interrupting thread " + item.getId(); item.interrupt() } } {noformat} {noformat} def slaves = hudson.model.Hudson.instance.getNodes() for (slave in slaves) { def comp = slave.getComputer() def executors = comp.getExecutors() if (executors != null ) { for (executor in executors) { def workunit = executor.getCurrentWorkUnit() if (workunit != null) { def subtask = workunit.work println "Slavename:" + slave.getDisplayName() + ";Task:BUSY:" + subtask.getDisplayName() } else { println "Slavename:" + slave.getDisplayName() + ";Task:IDLE" } } } } {noformat} {noformat} def slaves = hudson.model.Hudson.instance.getNodes() for (slave in slaves) { def comp = slave.getComputer() if (comp.isOnline()) { println "Name:" + comp.getName() + "; Status: ONLINE; Hostname:" + comp.getHostName() + "; Idle:" + comp.countIdle() } else{ println "Name:" + comp.getName() + "; Status: OFFLINE; Hostname:NA" + "; Idle:0" } } {noformat}
    via by Markus,
  • I run frequent scripts on a node called "utils" using the groovy CLI to communicate with Jenkins. After a couple of hours, the CLI stops working. I've found several java.lang.OutOfMemoryError: unable to create new native thread in the log file. I've checked the memory and it uses 500 mb out of 1.5gb allocated. I searched the net and found that it could be caused by too many threads. I've done a thread dump and found that the node called "utils" has *1074 threads* that look like this: {panel} ComThread for Thread-1022 "ComThread for Thread-1022" Id=1497 Group=main RUNNABLE (in native) at com4j.Win32Lock.suspend0(Native Method) at com4j.Win32Lock.suspend(Win32Lock.java:33) at com4j.ComThread.run0(ComThread.java:135) at com4j.ComThread.run(ComThread.java:125) {panel} Finally, Jenkins crashes with out of memory. Attached is the thread dump. Any ideas? It started around the time when I finally understood how the groovy CLI scripts work and added a few of them. ------------------- The groovy scripts I run are: {noformat} Thread.getAllStackTraces().keySet().each() { item -> if (item.getName().contains("SCM polling") && item.getName().contains("waiting for hudson.remoting")) { println "Interrupting thread " + item.getId(); item.interrupt() } } {noformat} {noformat} def slaves = hudson.model.Hudson.instance.getNodes() for (slave in slaves) { def comp = slave.getComputer() def executors = comp.getExecutors() if (executors != null ) { for (executor in executors) { def workunit = executor.getCurrentWorkUnit() if (workunit != null) { def subtask = workunit.work println "Slavename:" + slave.getDisplayName() + ";Task:BUSY:" + subtask.getDisplayName() } else { println "Slavename:" + slave.getDisplayName() + ";Task:IDLE" } } } } {noformat} {noformat} def slaves = hudson.model.Hudson.instance.getNodes() for (slave in slaves) { def comp = slave.getComputer() if (comp.isOnline()) { println "Name:" + comp.getName() + "; Status: ONLINE; Hostname:" + comp.getHostName() + "; Idle:" + comp.countIdle() } else{ println "Name:" + comp.getName() + "; Status: OFFLINE; Hostname:NA" + "; Idle:0" } } {noformat}
    via by Markus,
    • java.lang.OutOfMemoryError: unable to create new native thread in the log file. I've checked the memory and it uses 500 mb out of 1.5gb allocated. I searched the net and found that it could be caused by too many threads. I've done a thread dump and found that the node called "utils" has *1074 threads* that look like this: {panel} ComThread for Thread-1022 "ComThread for Thread-1022" Id=1497 Group=main RUNNABLE (in native) at com4j.Win32Lock.suspend0(Native Method) at com4j.Win32Lock.suspend(Win32Lock.java:33) at com4j.ComThread.run0(ComThread.java:135) at com4j.ComThread.run(ComThread.java:125)
    No Bugmate found.