Форум сайта python.su
0
Всем привет
Вообщем ситуация следующая, рисую я графики с помощью mathplot, много порядка 11 тысяч, это графики посещаемости минутные и часовые. Ругается mathplot сначало говорит
C:\Python27\lib\site-packages\matplotlib\pyplot.py:424: RuntimeWarning: More than 20 figures have been opened. Figures created through the pyplot interface (`matplotlib.pyplot.figure`) are retained until explicitly closed and may consume too much memory. (To control this warning, see the rcParam `figure.max_open_warning`).
max_open_warning, RuntimeWarning)
потом подвисает вылетает и пишет
Fail to allocate bitmap
This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.
tried to delete photo image when instances still exist
This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.
Что посоветуете как быть??
вот код функции которая рисует
def paint_all(self, dir): dir = dir self.count_cord() dir = os.path.join(dir) if not os.path.isdir(dir): os.makedirs(dir) #Paint Mins Graf t_min = self.all_min_count.keys() s_min = self.all_min_count.values() #grid(True) figure() plot(t_min, s_min) savefig(os.path.join(dir, "all_mins.png")) #Paint Hours Graf t_hour = self.all_hour_count.keys() s_hour = self.all_hour_count.values() #grid(True) figure() plot(t_hour, s_hour) savefig(os.path.join(dir, "all_hours.png")) #Paint Id mins for tid in self.tid_min_count.keys(): t_min = self.tid_min_count[tid].keys() s_min = self.tid_min_count[tid].values() grid(True) figure() plot(t_min, s_min) savefig(os.path.join(dir, str(tid)+"_min.png")) #Paint id hours for tid in self.tid_hour_count.keys(): t_hour = self.tid_hour_count[tid].keys() s_hour = self.tid_hour_count[tid].values() grid(True) figure() plot(t_hour, s_hour) savefig(os.path.join(dir, str(tid)+"_hour.png"))

Офлайн
857
Mazay_KaНадо поискать, как закрывать графики, чтобы они память не занимали. Как график нарисовал, надо ресурсы освободить.
More than 20 figures have been opened. Figures created through the pyplot interface (`matplotlib.pyplot.figure`) are retained until explicitly closed
Отредактировано py.user.next (Янв. 9, 2015 04:28:01)
Офлайн
49
matplotlib освобождает память при вызове метода show(), но поскольку вам этого не нужно, решение тут: http://stackoverflow.com/questions/7101404/how-can-i-release-memory-after-creating-matplotlib-figures
и тут: http://stackoverflow.com/questions/7125710/matplotlib-errors-result-in-a-memory-leak-how-can-i-free-up-that-memory
Отредактировано Alen (Янв. 9, 2015 07:11:10)
Офлайн
0
Спасибо
Офлайн