RE: PyNumber_Int screwing Object.

Discussion in 'Python' started by Tim Peters, Oct 7, 2003.

  1. Tim Peters

    Tim Peters Guest

    [Bengt Richter]
    > A thought -- is there any guarantee that there will be enough memory
    > to process an oom exception?


    Read your OS owner's manual and see what guarantees they make when you're
    out of memory. Python can't guarantee more than that. The internal
    PyErr_NoMemory() tries to use a preallocated instance of the MemoryError
    class so that it won't run out of memory again trying to raise the
    exception, but there's certainly no guarantee you have enough memory to get
    into a Python function after that.

    > Could there be an app-accessible s/w lever somewhere that one could
    > kick over for reserve memory (assuming getting to the exception
    > handler is guaranteed), like my old VW bug used to have?
    >
    > It would sputter and lunge when I "ran out" of gas on the freeway to
    > work, and I'd just kick the little black lever on the firewall over
    > 90 degrees, and sputter, lunge, continue (don't want to forget the
    > state of that lever though ;-)


    On systems where the C library supports flip_malloc_reserve_lever(), no
    problem. On other systems Python could hold one byte in reserve, just as
    soon as you contribute code to make that happen <wink>.
     
    Tim Peters, Oct 7, 2003
    #1
    1. Advertising

  2. On Mon, 6 Oct 2003 20:07:54 -0400, "Tim Peters" <> wrote:

    >[Bengt Richter]
    >> A thought -- is there any guarantee that there will be enough memory
    >> to process an oom exception?

    >
    >Read your OS owner's manual and see what guarantees they make when you're
    >out of memory. Python can't guarantee more than that. The internal
    >PyErr_NoMemory() tries to use a preallocated instance of the MemoryError
    >class so that it won't run out of memory again trying to raise the
    >exception, but there's certainly no guarantee you have enough memory to get
    >into a Python function after that.
    >
    >> Could there be an app-accessible s/w lever somewhere that one could
    >> kick over for reserve memory (assuming getting to the exception
    >> handler is guaranteed), like my old VW bug used to have?
    >>
    >> It would sputter and lunge when I "ran out" of gas on the freeway to
    >> work, and I'd just kick the little black lever on the firewall over
    >> 90 degrees, and sputter, lunge, continue (don't want to forget the
    >> state of that lever though ;-)

    >
    >On systems where the C library supports flip_malloc_reserve_lever(), no
    >problem. On other systems Python could hold one byte in reserve, just as

    one byte? how about a configurable amount defaulting to a meg?
    >soon as you contribute code to make that happen <wink>.

    I had the unverified impression that python got raw memory for small stuff wholesale,
    and suballocated from its own pools, so the issue would seem to come up when either
    replenishing the pools fails, or an app-level allocation of something large fails.
    Either way, if you replenished pools from a reserved wholesale chunk at that point, perhaps
    things could unwind better, assuming that the unwinding process doesn't try to allocate more
    big stuff? It might even recover, if the reserve could be re-established after
    the exception was handled. Of course, people couldn't use exception catchalls willy-nilly.

    Regards,
    Bengt Richter
     
    Bengt Richter, Oct 7, 2003
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Chris

    Screwing up my HTML

    Chris, Oct 22, 2003, in forum: ASP .Net
    Replies:
    3
    Views:
    388
    Chris
    Nov 5, 2003
  2. Darrel
    Replies:
    0
    Views:
    995
    Darrel
    Dec 28, 2004
  3. =?iso-8859-1?Q?Jos=E9_Rui_Faustino_de_Sousa?=

    PyNumber_Int screwing Object.

    =?iso-8859-1?Q?Jos=E9_Rui_Faustino_de_Sousa?=, Oct 6, 2003, in forum: Python
    Replies:
    0
    Views:
    423
    =?iso-8859-1?Q?Jos=E9_Rui_Faustino_de_Sousa?=
    Oct 6, 2003
  4. Tim Peters

    RE: PyNumber_Int screwing Object.

    Tim Peters, Oct 6, 2003, in forum: Python
    Replies:
    2
    Views:
    320
    =?iso-8859-1?Q?Jos=E9_Rui_Faustino_de_Sousa?=
    Oct 6, 2003
  5. Daniel Kramer

    string parsing screwing up on large files?

    Daniel Kramer, Dec 20, 2003, in forum: Python
    Replies:
    2
    Views:
    312
    Bengt Richter
    Dec 20, 2003
Loading...

Share This Page