473,573 Members | 2,511 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2194
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 tdronsk <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 tdronsk <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*******@yaho o.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*******@yaho o.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*******@yaho o.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.com wrote:
globalrev <sk*******@yaho o.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
2852
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
2166
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 such a bad language it amazes me everytime :D Just look at this shit: unsigned short int i;
24
1660
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 thing was what actually turn this while loop into an endless loop instead of waiting for user response it'll would skip right over it. Could ...
13
1770
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 <stdlib.h> int resize(int *incsize, int min_size) { while(*incsize <= min_size) { *incsize = (int)(*incsize * 1.25); } if ( min_size > 60 ) return...
73
4567
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 endless loop in a line with: if a==b: print 'OK' I mean, it would be of much help to me on my way to understanding Python to know how such prefix...
6
500
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 output(unsigned char ret_buffer, int curr_buffer_size, bool& endoffile) { int index2=0; int addr=0; unsigned char outBuff;
0
7668
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7983
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8179
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7735
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
8035
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
5257
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3698
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
2166
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1269
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.