'OutOfMemoryError: Java heap space in docker-compose

I am doing quite expensive for the memory parsing of 50000 HTML pages. While parsing, I am writing them to the database which is defined in my docker-compose.yml file. After 25000 pages are parsed parsing stops and I get such an error:

AsyncExecutor.default-11" java.lang.OutOfMemoryError: Java heap space

How can I change Java heap size in my docker-compose file so all the data could fit into the database?

My docker-compose file looks like this:

version: '2'
services:
  app:
    image: "user/app:latest"
    depends_on:
      - "db"
  api:
    image: "user/=api:latest"
    ports:
      - "7070:7070"
    depends_on:
      - "db"
  db:
    image: postgres
    environment:
      JVM_OPTS: "-Xms8g -Xms8g"
      POSTGRES_DB: postgresdb
      POSTGRES_USER: user
      POSTGRES_PASSWORD: password

I would be grateful for any advice!



Solution 1:[1]

I've faced the same problem, I did limit the service memory usage (ex. I used 800m) by adding the following attribute: "mem_limit: 800m"

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 BOUZAR