mbrc's blog

By mbrc, history, 6 years ago, In English

According to the blog about languages, the -Xmx option for Java is set to 512M. So consider 1097F - Alex and a TV Show from Hello 2019, with a ML of 256M. In this problem, my submission 47948716 takes > 200M memory. With n = 1e5, q = 1e6, t = 1, x = <cycle through 1 .. n>, v = 1,the code takes ~207M on Custom Test. But by setting -Xmx130M, this still runs on my system in time (without -Xmx it took ~270M on my system). This probably means that Java doesn't garbage collect as it still has memory left.

Also according to the following StackOverflow answer: ...Java will use as much memory as it is allowed to, at which point it will garbage collect. To work around this, you can specify a smaller max heap size in the JVM settings. You do this with the -Xmx setting....

Since Codeforces sets the -Xmx to 512M and many problems have ML 256M, is it possible that a piece of code continues to take up memory (since it can go upto 512M) without garbage collecting, and consequently gets MLE verdict, when it could have actually done with 256M and some garbage collection?

  • Vote: I like it
  • +40
  • Vote: I do not like it

»
6 years ago, # |
  Vote: I like it +24 Vote: I do not like it

It did happen to me once but not on CF(I think it was on Yandex.Contest)

  • »
    »
    6 years ago, # ^ |
      Vote: I like it +8 Vote: I do not like it

    It seems possible. Idk if there are any guards against that on CF.

»
6 years ago, # |
  Vote: I like it +42 Vote: I do not like it

Hi, we don't use -Xmx512M now. Please, read https://codeforces.me/blog/entry/43696

  • »
    »
    6 years ago, # ^ |
      Vote: I like it +16 Vote: I do not like it

    Oh, didn't find that during search. Thanks! That's reassuring.