ENG  RUSTimus Online Judge
Online Judge
Задачи
Авторы
Соревнования
О системе
Часто задаваемые вопросы
Новости сайта
Форум
Ссылки
Архив задач
Отправить на проверку
Состояние проверки
Руководство
Регистрация
Исправить данные
Рейтинг авторов
Текущее соревнование
Расписание
Прошедшие соревнования
Правила
вернуться в форум

Обсуждение задачи 1439. Поединок с И-Так-Понятно-Кем

Memory Limit error with less then 5MB allocated to program
Послано VC67 8 май 2011 15:36
I'm have gotten "memory limit exceeded" on test 2. I try to solve this task with Fenwick tree in Java.
But "memory allocated" value in result table is only 4.7MB. Stated memory limit is 16MB, and some of accepted solution have almost 16MB allocated (ID 3136829 for example).




Edited by author 08.05.2011 15:37
Re: Memory Limit error with less then 5MB allocated to program
Послано VC67 8 май 2011 17:10
It seems that if programm tries to allocate real big chunk of memory, that does not show in result table. i.e. 5MB and 2 test is state of program before its attempt to allocate too many mem.
Re: Memory Limit error with less then 5MB allocated to program
Послано AterLux 8 май 2011 19:19
It's Java Memory Model.
On this server Java runs with minimal and maximal size of heap sets to 64 Mb.
When you creating new Java objects it allocated in heap and still there until garbage collection, even if you not using it. Since your program make calculations and not idle, Garbage collector can't collect in background an will run when most of memory will occuped
So, avoid to create multiple objects with short life-time, be carefull with explicit-created objects
For exapmle Scanner.nextInt explicit creating String object, that then converted into the integer, but String and associated char-array remains in memory.
Also any String you created (for example when reading from file) are remain in heap until the garbage collection: when reading from file use byte-by-byte reading, char reading instead of Scanners Strings and other