我有一个多线程爬虫。在这个程序中,如果我加载了很多种子,我会得到一个错误。我看到了java.lang.OutOfMemoryError
,想也许内存不够。我尝试crawler.jar
使用这些参数运行文件:java -Xms512m -Xmx3G -jar crawler.jar
但到目前为止,还没有运气。
这是程序的 StackTrace:
Exception in thread "main" java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader.main(JarRsrcLoader.java:58)
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:597)
at com.sleepycat.je.utilint.DaemonThread.runOrPause(DaemonThread.java:99)
at com.sleepycat.je.dbi.EnvironmentImpl.runOrPauseDaemons(EnvironmentImpl.java:772)
at com.sleepycat.je.dbi.EnvironmentImpl.envConfigUpdate(EnvironmentImpl.java:717)
at com.sleepycat.je.dbi.EnvironmentImpl.finishInit(EnvironmentImpl.java:579)
at com.sleepycat.je.dbi.DbEnvPool.getEnvironment(DbEnvPool.java:204)
at com.sleepycat.je.Environment.makeEnvironmentImpl(Environment.java:230)
at com.sleepycat.je.Environment.<init>(Environment.java:212)
at com.sleepycat.je.Environment.<init>(Environment.java:166)
...
这与我怀疑的记忆有关吗?-Xms512m -Xmx3G
当我使用运行 jar 文件时添加工作java -jar
吗?
我运行了任务管理器(我在 Windows Server 上运行),但运行应用程序后,内存并没有那么高!我错了吗?