Fill memeory with endless loop?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • globalrev

    #1

    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?

  • Filip =?utf-8?B?xaB0xJtkcm9uc2vDvQ==?=

    #2
    Re: Fill memeory with endless loop?

    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.



    Comment

    • Mensanator

      #3
      Re: Fill memeory with endless loop?

      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".

      Comment

      • globalrev

        #4
        Re: Fill memeory with endless loop?

        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?

        Comment

        • Gabriel Genellina

          #5
          Re: Fill memeory with endless loop?

          En Tue, 13 May 2008 15:18:31 -0300, globalrev <skanemupp@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

          Comment

          • Tim Roberts

            #6
            Re: Fill memeory with endless loop?

            globalrev <skanemupp@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, timr@probo.com
            Providenza & Boekelheide, Inc.

            Comment

            • Bruno Desthuilliers

              #7
              Re: Fill memeory with endless loop?

              Tim Roberts a écrit :
              globalrev <skanemupp@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 !-)

              Comment

              • Grant Edwards

                #8
                Re: Fill memeory with endless loop?

                On 2008-05-14, Tim Roberts <timr@probo.com wrote:
                globalrev <skanemupp@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

                Comment

                Working...