Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > program loaded in memory

Reply
Thread Tools

program loaded in memory

 
 
Anatoli Hristov
Guest
Posts: n/a
 
      10-22-2012
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
 
Reply With Quote
 
 
 
 
Steven D'Aprano
Guest
Posts: n/a
 
      10-22-2012
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
 
Reply With Quote
 
 
 
 
Grant Edwards
Guest
Posts: n/a
 
      10-22-2012
On 2012-10-22, Steven D'Aprano <steve+> 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.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: program loaded in memory Dave Angel Python 0 10-22-2012 12:47 AM
Re: program loaded in memory Anatoli Hristov Python 0 10-22-2012 12:31 AM
How JVM is loaded in your program ? koolViru Java 7 09-04-2005 10:37 AM
java -verbose doesn't show "loaded from" for classes loaded from custom jars in the classpath Udo Corban Java 0 01-23-2004 09:32 AM
Re: how to programatically give assembly loaded from network the same trust as those loaded from local host? Marcelo Birnbach [MS] ASP .Net 0 06-27-2003 11:51 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57