How can I calculate memory of a program to avoid MLE? Thanks!
# | User | Rating |
---|---|---|
1 | tourist | 3690 |
2 | jiangly | 3647 |
3 | Benq | 3581 |
4 | orzdevinwang | 3570 |
5 | Geothermal | 3569 |
5 | cnnfls_csy | 3569 |
7 | Radewoosh | 3509 |
8 | ecnerwala | 3486 |
9 | jqdai0815 | 3474 |
10 | gyh20 | 3447 |
# | User | Contrib. |
---|---|---|
1 | maomao90 | 174 |
2 | awoo | 165 |
3 | adamant | 161 |
4 | TheScrasse | 160 |
5 | nor | 158 |
6 | maroonrk | 156 |
7 | -is-this-fft- | 152 |
8 | orz | 146 |
9 | pajenegod | 145 |
9 | SecondThread | 145 |
How can I calculate memory of a program to avoid MLE? Thanks!
Name |
---|
To get an estimate you can check your array usage and STL container usage.
For array it will be memory of primitive type * array size, say int $$$x[1000][1000]$$$ uses $$$4 bytes * 1000 *1000 = 4MB$$$
For STL containers it will be a constant factor for that container * memory of primitive type * size + some constant (ignore as the first term will dominate) A ref here
In fact CF standard memory limit are so loose and you don't need to care at most cases. And the memory usage shown may differ < 1600KB from actual. I think you can forget those things and solve some problems first.
PS: In C/C++ a boolean takes 1 byte. If you want a boolean array with tight memory limit, use a char array and store 4 boolean in one char or use C++ bitset library. I remember there is such a question in contest in few years ago.