Блог пользователя HOMIARA_RUBY

Автор HOMIARA_RUBY, история, 7 лет назад, По-английски

I'm learning OOP using Java. So you may find my question 'like dumb'. I have followed Java coders code like this not this. why? I thought Java has garbage collection system(not like destructor in C++) which is called randomly(As far I know). So creating lot of objects will result MLE(if no garbage collection is called during execution time and if an object take N space and we create M objects then it should take N*M space which may result MLE). So in Codeforces 'custom invocation' I tried to do experiment and see what happens. I did the same experiment in 'Ideone'. I found almost no difference (i thought M times larger for M objects) in terms of memory. Why?

I have asked the question here because Codeforces community is more responsive.

  • Проголосовать: нравится
  • +2
  • Проголосовать: не нравится

»
7 лет назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

You're hitting around 60 ~ 70 MB, (I guessed 1e7 * 8 would give you around 80 MB, there might be some optimization)

How would this "MLE"? I think most online judges allot 256 MB.

  • »
    »
    7 лет назад, # ^ |
      Проголосовать: нравится +8 Проголосовать: не нравится

    If I create enough objects then it should show MLE(according to my logic). I assume no finalize()/garbage collection is executed (since it is unpredictable) during out program execution. if an objects take 60~70 MB and our program have 10 test_cases(so 10 objects) then it should take 10*60=600 MB. But the first code is fine. there no excessive objects are created. I wanted to know why i couldn't get this memory allocation difference clearly.

    • »
      »
      »
      7 лет назад, # ^ |
        Проголосовать: нравится +8 Проголосовать: не нравится

      10 test case means; I'm talking about the problem that states for 'several/multiple input test case' within same memory limit and time limit.