473,385 Members | 1,848 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Fill memeory with endless loop?

if i do something like
while 1:
print "x"

will the program ever stop because it runs out of memory? or is the
print x never stored somewhere?
if u do soemhting like add element to a list it has an upper nbr of
elements right? if though huge...
does windows or any other OS have some proces that would stop
something like this after a while? could be interpreted a s a virus
perhaps?

Jun 27 '08 #1
7 2183
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 (except output buffers, terminal scrollback, etc.,
but all of this is temporary and of limited size). In case of
adding elements to a list, the memory usage can, of course,
grow unlimitedly. On linux, if the process eats up too much
memory, it gets killed. I do not know about windows, but
they would probably crash with a BSOD or something of that
sort.

Jun 27 '08 #2
On May 13, 11:59*am, Filip ©tìdronský <regn...@seznam.czwrote:
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 (except output buffers, terminal scrollback, etc.,
but all of this is temporary and of limited size). In case of
adding elements to a list, the memory usage can, of course,
grow unlimitedly. On linux, if the process eats up too much
memory, it gets killed. I do not know about windows, but
they would probably crash with a BSOD or something of that
sort.
Usually, Windows just says "out of memory".
Jun 27 '08 #3
On 13 Maj, 18:59, Filip ©tìdronský <regn...@seznam.czwrote:
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 (except output buffers, terminal scrollback, etc.,
but all of this is temporary and of limited size). In case of
adding elements to a list, the memory usage can, of course,
grow unlimitedly. On linux, if the process eats up too much
memory, it gets killed. I do not know about windows, but
they would probably crash with a BSOD or something of that
sort.

and when the program get skiled because out of memory all this will be
deleted from the memory?

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?
Jun 27 '08 #4
En Tue, 13 May 2008 15:18:31 -0300, globalrev <sk*******@yahoo.se>
escribió:
On 13 Maj, 18:59, Filip Å*tÄ›dronský <regn...@seznam.czwrote:
>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

Jun 27 '08 #5
globalrev <sk*******@yahoo.sewrote:
>
and when the program get skiled because out of memory all this will be
deleted from the memory?
Yes. When a process is killed, all of the memory it was using is released.
>so there is no way that you can, by accident, fill your whole
harddrive and make it unusable?
Of course not. Where do you see a connection between memory and your hard
drive?

Now, you can certainly fill your hard drive by running your little infinite
loop application and storing the results in a file:
python looper.py saveme.txt
but I hope it is clear to you that this can't damage any of the data you
already have.
>and RAM-memory always get cleaned out when not used i guess?
It gets released so that it can be re-used. I don't know what you mean by
"cleaned out". Remember that most of the systems where Python runs are
virtual memory systems, so even if one application is using a couple of
gigabytes of memory, other applications are still able to run.
--
Tim Roberts, ti**@probo.com
Providenza & Boekelheide, Inc.
Jun 27 '08 #6
Tim Roberts a écrit :
globalrev <sk*******@yahoo.sewrote:
>and when the program get skiled because out of memory all this will be
deleted from the memory?

Yes. When a process is killed, all of the memory it was using is released.
>so there is no way that you can, by accident, fill your whole
harddrive and make it unusable?

Of course not. Where do you see a connection between memory and your hard
drive?
swap.

But that won't "fill your whole harddrive", indeed !-)

Jun 27 '08 #7
On 2008-05-14, Tim Roberts <ti**@probo.comwrote:
globalrev <sk*******@yahoo.sewrote:
>>and when the program gets killed because out of memory all this
will be deleted from the memory?

Yes. When a process is killed, all of the memory it was using
is released.
>>so there is no way that you can, by accident, fill your whole
harddrive and make it unusable?

Of course not. Where do you see a connection between memory
and your hard drive?

Now, you can certainly fill your hard drive by running your
little infinite loop application and storing the results in a
file:
Again, that's only a problem if the OS lets it be problem. No
real OS will let a drive become unusable because of a runaway
user program. Any decent filesystem can provide per-user disk
quotas and a "reserve" of space for system/root use.

--
Grant Edwards grante Yow! I just had a NOSE
at JOB!!
visi.com
Jun 27 '08 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: John F. | last post by:
Hi all, I'm searching fulltime for days now, and I don't find the solution, so I'm thinking this is more a bug :( If i use following code in form&subforms:
30
by: Skybuck Flying | last post by:
I was just trying to figure out how some C code worked... I needed to make a loop to test all possible values for a 16 bit word. Surprise Surprise... C sucks at it... once again :D lol... C is...
24
by: Tweaxor | last post by:
This has been puzzling me all this week. This is actually a homework assignment from last semesmter. But the teacher wouldn't tell us why certain things didn't work, but it didn't just work. My...
13
by: Bev in TX | last post by:
We are using Visual Studio .NET 2003. When using that compiler, the following example code goes into an endless loop in the "while" loop when the /Og optimization option is used: #include...
73
by: Claudio Grondi | last post by:
In the process of learning about some deeper details of Python I am curious if it is possible to write a 'prefix' code assigning to a and b something special, so, that Python gets trapped in an...
6
by: uche | last post by:
This function that I have implemented gives me an infinite loop. I am trying to produce a hexdum program, however, this function is not functioning correctly.....Please help. void...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.