Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

OutOfMemoryError: Java Heap Space  RSS feed

 
Andrew Gray
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey,

I'm currently writing a insertion sort method and i'm getting this outofmemory error and I'm confused as to why, any help would be appreciated.

 
Jeanne Boyarsky
author & internet detective
Sheriff
Posts: 37230
519
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Andrew,
My guess is there is an infinite loop. Does this condition ever fail to be true? You can check by adding some printlns and post back here with what the last one to run is.

 
Embla Tingeling
Ranch Hand
Posts: 237
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Also convince yourself that the in method terminates and not keep adding numbers to the array indefinately for some reason.

 
Satya Maheshwari
Ranch Hand
Posts: 368
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
At line 57


you unconditionally add key to the list, regardless of any shifting happening or not. That's causing the num list to grow infinitely.
Additionally, using an arraylist functions is'nt making life easier and could be done quite simply using a plain array.
 
Jeff Yan
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hey im guessing you are at newcastle university because i am doing the same code haha. id shift the contents after reading it in to an arrayList and then transfer it over to a plain array using the .toArray() method of the arrayList collections!!! IT MAKES IT FAR EASIER!!! hu is this by the way?
 
Maya Naga
Ranch Hand
Posts: 79
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i try to write program to count compressed files ...
but whenever i start to run the application it ends with error ut of memory: java heap space

Am using opensuse...
i went with all solutions which was given here before.. but yet am getting same error..

here is my code:


can any one help how to set the heap space permanently or to that specific program...
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!