java.lang.OutOfMemoryError:无法创建遇到的新本机线程

时间:2012-02-29 19:46:06

标签: java multithreading hadoop java.util.concurrent

我正在使用线程池来完成一些工作。我的泳池大小只有8。 但是我收到了以下错误:

java.util.concurrent.ExecutionException: java.lang.OutOfMemoryError: unable to create new native thread
    at java.util.concurrent.FutureTask$Sync.innerGet(FutureTask.java:222)
    at java.util.concurrent.FutureTask.get(FutureTask.java:83)
    at com.TransferFiles.transferFilesToHadoop(TransferFiles.java:88)
    at com.TransferJob.execute(TransferJob.java:25)
    at org.quartz.core.JobRunShell.run(JobRunShell.java:202)
    at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:525)
Caused by: java.lang.OutOfMemoryError: unable to create new native thread
    at java.lang.Thread.start0(Native Method)
    at java.lang.Thread.start(Thread.java:640)
    at org.apache.hadoop.ipc.Client$Connection.setupIOstreams(Client.java:555)
    at org.apache.hadoop.ipc.Client$Connection.access$1800(Client.java:184)
    at org.apache.hadoop.ipc.Client.getConnection(Client.java:1140)
    at org.apache.hadoop.ipc.Client.call(Client.java:986)
    at org.apache.hadoop.ipc.RPC$Invoker.invoke(RPC.java:225)
    at $Proxy1.getFileInfo(Unknown Source)
    at sun.reflect.GeneratedMethodAccessor12.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.apache.hadoop.io.retry.RetryInvocationHandler.invokeMethod(RetryInvocationHandler.java:82)
    at org.apache.hadoop.io.retry.RetryInvocationHandler.invoke(RetryInvocationHandler.java:59)
    at $Proxy1.getFileInfo(Unknown Source)
    at org.apache.hadoop.hdfs.DFSClient.getFileInfo(DFSClient.java:676)
    at org.apache.hadoop.hdfs.DistributedFileSystem.getFileStatus(DistributedFileSystem.java:521)
    at org.apache.hadoop.fs.FileSystem.exists(FileSystem.java:692)
    at org.apache.hadoop.fs.FileUtil.checkDest(FileUtil.java:349)
    at org.apache.hadoop.fs.FileUtil.copy(FileUtil.java:205)
    at org.apache.hadoop.fs.FileSystem.copyFromLocalFile(FileSystem.java:1119)
    at org.apache.hadoop.fs.FileSystem.copyFromLocalFile(FileSystem.java:1095)
    at com.FileCopyRoutine.call(TransferFiles.java:325)
    at com.FileCopyRoutine.call(TransferFiles.java:257)
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
    at java.util.concurrent.FutureTask.run(FutureTask.java:138)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
    at java.lang.Thread.run(Thread.java:662)

我正在使用:

private static final ExecutorService exec = Executors.newFixedThreadPool(TransferToHadoopUtilities.numOfThreads);

numOfThreads = 8

Future<Boolean> futureTask =  exec.submit(new FileCopyRoutine(srcSubResultPath, destSubResultPath,execId));

FileCopyRoutine实现Callable。我可能会同时提交数百个。 有人可以给我一些关于这个错误的提示吗?

非常感谢!!!

1 个答案:

答案 0 :(得分:0)

无法创建线程表示本机内存 - 不是堆。如果您使用的是32位系统,将-Xmx设置为TOO为高可能会使本机内存不足