spring使用线程启动时出现内存不足异常

jk9hmnmh  于 2021-07-03  发布在  Java
关注(0)|答案(0)|浏览(191)

我有一个springboot应用程序,我使用线程从csv文件读取数据并将它们存储在数据库中。但我的内存正在耗尽。cpu被完全利用。我怎样才能解决这个问题?
有没有办法从jvm参数中增加堆的大小?

@Bean(name = "MainDepositExecutor")
  @Primary
  public TaskExecutor workExecutor() {
    ThreadPoolTaskExecutor threadPoolTaskExecutor = new ThreadPoolTaskExecutor();
    threadPoolTaskExecutor.setCorePoolSize(taskCorePoolSize);
    threadPoolTaskExecutor.setMaxPoolSize(maximumThreadPoolSize);
    threadPoolTaskExecutor.setQueueCapacity(queueCapacity);
    threadPoolTaskExecutor.afterPropertiesSet();
    log.info("mainDepositExecutor ThreadPoolTaskExecutor set");
    return threadPoolTaskExecutor;
  }

where taskCorePoolSize=1
maximumThreadPoolSize=1
queueCapacity=50

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题