Fill memeory with endless loop?

Gabriel Genellina gagsl-py2 at yahoo.com.ar
Wed May 14 01:22:59 EDT 2008


En Tue, 13 May 2008 15:18:31 -0300, globalrev <skanemupp at yahoo.se>  
escribió:
> On 13 Maj, 18:59, Filip Štědronský <regn... at seznam.cz> wrote:
>> On Út, kvě 13, 2008 at 06:49:33 +0200, globalrev wrote:
>>
>> > if i do something like
>> > while 1:
>> >     print "x"
>>
>> > will the program ever stop because it runs out of memory?
>>
>> No, there is no reason to run out of memory. This will simply
>> make an everlasting x-printer and there is no need to store
>> anything [...]
>
> and when the program get skiled because out of memory all this will be
> deleted from the memory?

Yes. That's the operating system job.

> so there is no way that you can, by accident, fill your whole
> harddrive and make it unusable?
>
> and RAM-memory always get cleaned out when not used i guess?

We were talking of RAM, including virtual memory backed by disk space.
You *may* fill your whole disk if you keep writing data. If you invoke  
your example above using:
python neverending.py > output
the "output" file will grow indefinitely until you kill the program or you  
get a "disk full" exception.
That disk space is not cleared when the program exits - you have to  
explicitely delete the file.
Note that none of this is Python specific.

-- 
Gabriel Genellina




More information about the Python-list mailing list