Discussion
Loading...

Post

  • About
  • Code of conduct
  • Privacy
  • Users
  • Instances
  • About Bonfire
Klaus Frank
@agowa338@chaos.social  ·  activity timestamp last week

One of the biggest weaknesses of #Java is that it doesn't allow for dynamically increasing the memory after an application started.

Like I've about 500 GB of system memory and an application just crashed cause java wouldn't allow it to use more than 256 MB! That's ridiculous.

3
  • Copy link
  • Flag this post
  • Block
Bastelwombat
@bastelwombat@chaos.social replied  ·  activity timestamp last week

@agowa338 You can modify the limit using the -Xmx setting. E.g.:

java -Xmx8g yourProgram.jar

I guess a benefit of this design is, that you can reliably plan the upper limit of what your program can consume, so that it will never crash other applications on the same machine.

1
  • Copy link
  • Flag this comment
  • Block
Klaus Frank
@agowa338@chaos.social replied  ·  activity timestamp last week

@bastelwombat

I know, but I can't do that at runtime after the application already started. And when you're processing e.g. 1 TB of data starting over again because you hit this limit is quite shitty.

Also increasing it in general is also not desirable as it'll cause the Java process to get swapped to disk more easily (at least for most people that don't have 500 GB of ram like I do) and thereby impact traffic the 99% of times they don't exceed this limit.

Either way Java lacks dynamic alloc

  • Copy link
  • Flag this comment
  • Block
argv minus one
@argv_minus_one@mastodon.sdf.org replied  ·  activity timestamp last week

@agowa338

With a garbage collector like Java's, memory usage goes up but doesn't go down until hitting the limit (256MB in your case), and then the garbage collector kicks in and looks for unused memory to make available again.

If you don't impose an upper limit like that, how will the garbage collector know when to kick in?

  • Copy link
  • Flag this comment
  • Block
Schenkl | 🏳️‍🌈🦄
@schenklklopfer@chaos.social replied  ·  activity timestamp last week

@agowa338 Isn't it because Java would just reseve the full 500GB Memory, but still crashes when using more than 256MB...?

1
  • Copy link
  • Flag this comment
  • Block
Klaus Frank
@agowa338@chaos.social replied  ·  activity timestamp last week

@schenklklopfer

No, it never reserved more. It just crashed when the JVM heap exceeded 256 MB...

  • Copy link
  • Flag this comment
  • Block
Log in

Kakapo Social

Kakapo Social: About · Code of conduct · Privacy · Users · Instances
Bonfire social · 1.0.0 no JS en
Automatic federation enabled
  • Explore
  • About
  • Members
  • Code of Conduct
Home
Login