HOMIARA_RUBY's blog

By HOMIARA_RUBY, history, 4 years ago, In English

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.

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

»
4 years ago, # |
  Vote: I like it 0 Vote: I do not like it

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.

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

    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.

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

      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.