spring-templates / spring-concurrency-thread

Spring 프레임워크에서의 Thread 동시성 제어 문제를 다룹니다.
https://spring-templates.github.io/spring-concurrency-thread/
MIT License
0 stars 1 forks source link

AtomicCounter 테스트 #33

Closed ooMia closed 5 months ago

ooMia commented 5 months ago

Describe the bug

32 에 AtomicCounterTest에서 아래 그림처럼 카운트 횟수를 지정하는 totalCount를 Integer.MAX_VALUE로 하면 Out Of Memory가 뜨는 문제가 발생합니다.

image
Caused by: java.lang.OutOfMemoryError: Java heap space
    at java.base/java.util.concurrent.AbstractExecutorService.newTaskFor(AbstractExecutorService.java:98)
    at java.base/java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:122)
    at com.thread.concurrency.AtomicCounterTest.여러_더하기_수행_Executor(AtomicCounterTest.java:37)
    at java.base/java.lang.invoke.LambdaForm$DMH/0x000000a000288800.invokeVirtual(LambdaForm$DMH)
    at java.base/java.lang.invoke.LambdaForm$MH/0x000000a000190800.invoke(LambdaForm$MH)
    at java.base/java.lang.invoke.Invokers$Holder.invokeExact_MT(Invokers$Holder)

To Reproduce Steps to reproduce the behavior:

  1. Go to src/test/java/com/thread/concurrency/AtomicCounterTest.java
  2. totalCount를 Integer.MAX_VALUE로 변경
  3. 테스트 실행
  4. See error

Expected behavior A clear and concise description of what you expected to happen.

Originally posted by @haxr369 in https://github.com/spring-templates/spring-concurrency-thread/issues/32#issuecomment-2033561044