Search code examples
kotlinintellij-ideaheap-memory

Java heap space kotlin and IntelliJ


I'm trying to read a big cvs file (3500000 records) with IntelliJ Idea and Kotlin on a console application, but i have a problem with the heap spece:

Exception in thread "main" java.lang.OutOfMemoryError: Java heap space

img error

I tried to increase the heap size to different values like 2048MB or E.G. 10000MB but it does't work and i'm not able to find a solution.

data class  Product(
val year: Int,
val month: Int,
val cod_product: Int,
val unit: Int,
val country: Int,
val uf: String,
val transport: Int,
val revenue: Int,
val quantity: Int,
val weight: Int,
val price: Int

)

And i'm using var products: MutableList<Product> = ArrayList() to store the data


Solution

  • What worked for me was adding this lines into the main gradle of the project (not module) inside allprojects -> repositories

    tasks.withType(org.jlleitschuh.gradle.ktlint.tasks.BaseKtLintCheckTask).configureEach {
        it.workerMaxHeapSize.set("512m")
    }