ActiveMQ: outOfMemoryError: unable to create new native thread
Tag : rest , By : Brianna
Date : March 29 2020, 07:55 AM
may help you . The reason for this memory leak lies within activemq's connection handling. The default servlet creates one connection for each httpsession (which is a really bad idea). Me loadtesting tool doesn't care about sessions and doesn't send a session-id. So every message that was send is a new connection, is a new thread and after 17.000 threads the jvm is done. Basicly I'm going to write a new servlet that uses one connection per worker thread. That should limmit the threadnumber to a bare minimum.
|
OutOfMemoryError: unable to create new native thread using ExecutorService
Date : March 29 2020, 07:55 AM
With these it helps I'm not sure this is the only problem, but you are creating an ExecutorService in your checkState() method but you don't shut it down. According to the JavaDocs for Executors.newFixedThreadPool():
|
OutOfMemoryError: unable to create new native thread while using Executor
Tag : java , By : kokok13
Date : March 29 2020, 07:55 AM
it helps some times Just to supply an answer for future readers: The main idea of the solution is to initialize the ExecutorService instance only once and reuse it on each request (see comments above). public class MySqlResource{
private final ExecutorService executor;
public MySqlResource() {
this.executor = Executors.newFixedThreadPool(1);
}
@POST
@Path("insertOrUpdate")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public Response insertOrUpdate(final String user) {
try {
new MYSQLProvider().insertOrUpdate(user);
resulTObj.put("success", true);
resulTObj.put("msg", "");
executor.execute( new Runnable() {
@Override
public void run() {
//...run() code goes here
}
});
} catch (SQLException | JSONException e) {
// TODO Auto-generated catch block
e.printStackTrace();
resulTObj.put("success", false);
resulTObj.put("msg", e.getMessage());
}
return Response.status(200).entity(resulTObj.toString()).build();
}
}
public class MySqlResource {
//Note that the field is now static
private static final ExecutorService executor;
static {
MySqlResource.executor = Executors.newFixedThreadPool(1);
}
//.....
//Then the method can invoke it just as in the previous solution:
public Response insertOrUpdate(final String user) {
//...
MySqlResource.executor.execute( new Runnable() {
@Override
public void run() {
//...run() code goes here
}
});
//...
}
}
|
Evaluation - OutOfMemoryError: unable to create new native thread
Tag : java , By : Francis
Date : March 29 2020, 07:55 AM
it helps some times I wanted to know if there is an exact way to identify the root cause say the NOPROC has been exceeded etc
|
OutOfMemoryError: unable to create new native thread
Tag : java , By : user157654
Date : March 29 2020, 07:55 AM
|