Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #31868 > unrolled thread
| Started by | Anatoli Hristov <tolidtm@gmail.com> |
|---|---|
| First post | 2012-10-22 02:02 +0200 |
| Last post | 2012-10-22 14:19 +0000 |
| Articles | 3 — 3 participants |
Back to article view | Back to comp.lang.python
program loaded in memory Anatoli Hristov <tolidtm@gmail.com> - 2012-10-22 02:02 +0200
Re: program loaded in memory Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-10-22 02:50 +0000
Re: program loaded in memory Grant Edwards <invalid@invalid.invalid> - 2012-10-22 14:19 +0000
| From | Anatoli Hristov <tolidtm@gmail.com> |
|---|---|
| Date | 2012-10-22 02:02 +0200 |
| Subject | program loaded in memory |
| Message-ID | <mailman.2609.1350864150.27098.python-list@python.org> |
Hello,
I need an advice about a small script I run 24/24 7/7.
It's a script converted to EXE using py2exe and this script takes -
grows 30kb RAM on each loop which means that for 10hours it grows up
with 180mb memory. is there something I can do ?
>From the ini file I'm loading only the URL and the interval of
downloading the file
The script:
import time
import urllib
exec(open("iccm.ini").read())
loop = 0
while loop == 0:
time.sleep(interval*60)
try:
urllib.urlretrieve ('"'URL'"'+"/hours.xml", "c:\\config\\hours.xml")
except IOError:
pass
Thanks
[toc] | [next] | [standalone]
| From | Steven D'Aprano <steve+comp.lang.python@pearwood.info> |
|---|---|
| Date | 2012-10-22 02:50 +0000 |
| Message-ID | <5084b465$0$29897$c3e8da3$5496439d@news.astraweb.com> |
| In reply to | #31868 |
On Mon, 22 Oct 2012 02:02:27 +0200, Anatoli Hristov wrote:
> Hello,
>
> I need an advice about a small script I run 24/24 7/7.
>
> It's a script converted to EXE using py2exe and this script takes -
> grows 30kb RAM on each loop which means that for 10hours it grows up
> with 180mb memory. is there something I can do ?
Probably. Find the memory leak and fix it.
What happens if you call it directly from Python, instead of using py2exe?
Perhaps the memory leak is in py2exe.
> From the ini file I'm loading only the URL and the interval of
> downloading the file
> The script:
>
> import time
> import urllib
>
> exec(open("iccm.ini").read())
If you really must execute your data file as code, use:
execfile("iccm.ini")
in Python 2.x. Or better still, change the file to "iccm.py" and do:
from iccm import URL, interval
Or even better still, use the ConfigParser module to safely read the INI
file and extract data from it, without executing it as code. Who knows
what bugs might be caused by that?
> loop = 0
> while loop == 0:
Since that is never changed, the better way is:
while True: # loops forever
...
> time.sleep(interval*60)
> try:
> urllib.urlretrieve ('"'URL'"'+"/hours.xml",
> "c:\\config\\hours.xml")
That's not your code, because it gives a syntax error. That code cannot
run at all.
Please show us your ACTUAL code.
There are no obvious memory leaks in the code you show. Probably the
memory leak is in the code you haven't shown us.
--
Steven
[toc] | [prev] | [next] | [standalone]
| From | Grant Edwards <invalid@invalid.invalid> |
|---|---|
| Date | 2012-10-22 14:19 +0000 |
| Message-ID | <k63km1$f29$1@reader1.panix.com> |
| In reply to | #31875 |
On 2012-10-22, Steven D'Aprano <steve+comp.lang.python@pearwood.info> wrote:
> On Mon, 22 Oct 2012 02:02:27 +0200, Anatoli Hristov wrote:
>
>> Hello,
>>
>> I need an advice about a small script I run 24/24 7/7.
>>
>> It's a script converted to EXE using py2exe and this script takes -
>> grows 30kb RAM on each loop which means that for 10hours it grows up
>> with 180mb memory. is there something I can do ?
>
> Probably. Find the memory leak and fix it.
>
> What happens if you call it directly from Python, instead of using py2exe?
> Perhaps the memory leak is in py2exe.
I'm curious how there can be a memory leak in py2exe. I thought all
it did was bundle up the python interpreter and the required libraries
into a "private" python installation that's then invoked by the
wrapper. Does py2exe actually do something after the application has
started?
--
Grant Edwards grant.b.edwards Yow! ONE LIFE TO LIVE for
at ALL MY CHILDREN in ANOTHER
gmail.com WORLD all THE DAYS OF
OUR LIVES.
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.python
csiph-web