Fail to allocate bitmap, Unable to free colormap, palette is still selected.

hi,
I get this error when I'm generating numerous .png files using matplotlib 0.9.2 in py2.4 on WinXP

···

-----------------------------
Fail to allocate bitmap

This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.
Unable to free colormap, palette is still selected.

This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.
-----------------------------

The code is simple:
        import matplotlib
        import matplotlib.pyplot as pylab

        pylabFigure = pylab.figure()
        pylabFigure.clf()
        pylab.rcdefaults()
        pylab.plot(p[0::2], p[1::2], 'b-', linewidth=3)
        pylab.title('Endpointing Plot for '+StepMillName)
        pylab.xlabel('Mill Distance ('+m_unit+')')
        pylab.ylabel('~ Electron response ~' )
        pylab.grid(True)
        pylabFigure.savefig('EPP_'+StepMillName+'.png', facecolor='lightgrey', edgecolor='w')
        pylab.close('all')
        pylabFigure = None

I can put this code in a simple program and generate many images without seeing the allocate bitmap error.

Perhaps it is colliding with something else in my main app. Is there a command that can clear, flush, or unselect the palette and/or colormap?

I don't see the allocate error if I switch the backend to 'SVG', that has it own set of issues though: telling me it can't use, but then generating SVG files anyway.

thanks

--
Chris Kennedy http://www.coventor.com
Sr. Product Manager Ph: 919-854-7500 x156
Cary, NC

Can you provide the full traceback for the error? Are there no Python line numbers etc.?

I don't see the string "Fail to allocate bitmap" or "Unable to free colormap..." anywhere in the matplotlib source, so it's hard to say where it's coming from. I suspect they are coming from the GUI framework you are using...

If you put your simple example inside of a loop, does the error eventually occur -- or only within the context of your app? If the latter, we'll need to somehow narrow it down to a specific setting or method that causes the problem.

Also, what backend are you using when it breaks? Just Agg, or one of the Gui+Agg backends?

Cheers,
Mike

Chris Kennedy wrote:

···

hi,
I get this error when I'm generating numerous .png files using matplotlib 0.9.2 in py2.4 on WinXP
-----------------------------
Fail to allocate bitmap

This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.
Unable to free colormap, palette is still selected.

This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.
-----------------------------

The code is simple:
        import matplotlib
        import matplotlib.pyplot as pylab

        pylabFigure = pylab.figure()
        pylabFigure.clf()
        pylab.rcdefaults()
        pylab.plot(p[0::2], p[1::2], 'b-', linewidth=3)
        pylab.title('Endpointing Plot for '+StepMillName)
        pylab.xlabel('Mill Distance ('+m_unit+')')
        pylab.ylabel('~ Electron response ~' )
        pylab.grid(True)
        pylabFigure.savefig('EPP_'+StepMillName+'.png', facecolor='lightgrey', edgecolor='w')
        pylab.close('all')
        pylabFigure = None

I can put this code in a simple program and generate many images without seeing the allocate bitmap error.

Perhaps it is colliding with something else in my main app. Is there a command that can clear, flush, or unselect the palette and/or colormap?

I don't see the allocate error if I switch the backend to 'SVG', that has it own set of issues though: telling me it can't use, but then generating SVG files anyway.

thanks

--
Michael Droettboom
Science Software Branch
Operations and Engineering Division
Space Telescope Science Institute
Operated by AURA for NASA

hi Mike,
It only prints what is between the ----, ----- . I tend to think it is related to Tkinter.

I'm using the default GTKAgg.

I have generated over 1500 images using the simple example with no issue. When it is in the larger app, it fails on the 2nd or 3rd request.

I'm trying
    reload(matplotlib)
    matplotlib.use('TkAgg')

Are there some python flags I can use when running the script to get more verbose output? I've used -v and -d and get the cleanup list, is that useful?

thanks

Michael Droettboom wrote:

···

Can you provide the full traceback for the error? Are there no Python line numbers etc.?

I don't see the string "Fail to allocate bitmap" or "Unable to free colormap..." anywhere in the matplotlib source, so it's hard to say where it's coming from. I suspect they are coming from the GUI framework you are using...

If you put your simple example inside of a loop, does the error eventually occur -- or only within the context of your app? If the latter, we'll need to somehow narrow it down to a specific setting or method that causes the problem.

Also, what backend are you using when it breaks? Just Agg, or one of the Gui+Agg backends?

Cheers,
Mike

Chris Kennedy wrote:

hi,
I get this error when I'm generating numerous .png files using matplotlib 0.9.2 in py2.4 on WinXP
-----------------------------
Fail to allocate bitmap

This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.
Unable to free colormap, palette is still selected.

This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.
-----------------------------

The code is simple:
        import matplotlib
        import matplotlib.pyplot as pylab

        pylabFigure = pylab.figure()
        pylabFigure.clf()
        pylab.rcdefaults()
        pylab.plot(p[0::2], p[1::2], 'b-', linewidth=3)
        pylab.title('Endpointing Plot for '+StepMillName)
        pylab.xlabel('Mill Distance ('+m_unit+')')
        pylab.ylabel('~ Electron response ~' )
        pylab.grid(True)
        pylabFigure.savefig('EPP_'+StepMillName+'.png', facecolor='lightgrey', edgecolor='w')
        pylab.close('all')
        pylabFigure = None

I can put this code in a simple program and generate many images without seeing the allocate bitmap error.

Perhaps it is colliding with something else in my main app. Is there a command that can clear, flush, or unselect the palette and/or colormap?

I don't see the allocate error if I switch the backend to 'SVG', that has it own set of issues though: telling me it can't use, but then generating SVG files anyway.

thanks

--
Chris Kennedy http://www.coventor.com
Sr. Product Manager Ph: 919-854-7500 x156
Cary, NC Fx: 919-854-7501
                           Mobile: 919-414-6653

hi Mike,

I was able to get it to work using:

    reload(matplotlib)
    matplotlib.use('Agg')

I'll have to beat on it some more to see if this is robust.

I saw the error message in this code:

http://search.cpan.org/src/NI-S/Tk-804.027/pTk/mTk/win/tkWinDraw.c

    if(!bitmap) {
  panic("Fail to allocate bitmap\n");
  DeleteDC(dcMem);
      TkWinReleaseDrawableDC(d, dc, &state);
  return;
    }

thanks

Michael Droettboom wrote:

···

Can you provide the full traceback for the error? Are there no Python line numbers etc.?

I don't see the string "Fail to allocate bitmap" or "Unable to free colormap..." anywhere in the matplotlib source, so it's hard to say where it's coming from. I suspect they are coming from the GUI framework you are using...

If you put your simple example inside of a loop, does the error eventually occur -- or only within the context of your app? If the latter, we'll need to somehow narrow it down to a specific setting or method that causes the problem.

Also, what backend are you using when it breaks? Just Agg, or one of the Gui+Agg backends?

Cheers,
Mike

Chris Kennedy wrote:

hi,
I get this error when I'm generating numerous .png files using matplotlib 0.9.2 in py2.4 on WinXP
-----------------------------
Fail to allocate bitmap

This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.
Unable to free colormap, palette is still selected.

This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.
-----------------------------

The code is simple:
        import matplotlib
        import matplotlib.pyplot as pylab

        pylabFigure = pylab.figure()
        pylabFigure.clf()
        pylab.rcdefaults()
        pylab.plot(p[0::2], p[1::2], 'b-', linewidth=3)
        pylab.title('Endpointing Plot for '+StepMillName)
        pylab.xlabel('Mill Distance ('+m_unit+')')
        pylab.ylabel('~ Electron response ~' )
        pylab.grid(True)
        pylabFigure.savefig('EPP_'+StepMillName+'.png', facecolor='lightgrey', edgecolor='w')
        pylab.close('all')
        pylabFigure = None

I can put this code in a simple program and generate many images without seeing the allocate bitmap error.

Perhaps it is colliding with something else in my main app. Is there a command that can clear, flush, or unselect the palette and/or colormap?

I don't see the allocate error if I switch the backend to 'SVG', that has it own set of issues though: telling me it can't use, but then generating SVG files anyway.

thanks

--
Chris Kennedy http://www.coventor.com
Sr. Product Manager Ph: 919-854-7500 x156
Cary, NC

There seems to be some deep confusion here. You say you are using the
default GTKAgg, but then try "reload" (suggesting an interactive
session) and then call matplotlib.use('TkAgg') (which is never
appropriate when using TkAgg. Pleas explain to us a little more
clearly what you are trying to do: are you embedding matplotlib in a
UI, if so which on? Are you using it interactively from the python
shell (if so, which one?)

Note that if you are trying to build an app, as you suggest, ie embed
matplotlib in a GUI, you should not be using pylab at all. You should
follow the lead of examples/embedding_in_YOURGUI*.py , eg those at
http://matplotlib.sf.net/examples

JDH

···

On Fri, Feb 15, 2008 at 4:07 PM, Chris Kennedy <chris.kennedy@...1881...> wrote:

hi Mike,
It only prints what is between the ----, ----- . I tend to think it is
related to Tkinter.

I'm using the default GTKAgg.

I have generated over 1500 images using the simple example with no
issue. When it is in the larger app, it fails on the 2nd or 3rd request.

I'm trying
    reload(matplotlib)
    matplotlib.use('TkAgg')

Chris Kennedy wrote:

hi Mike,

I was able to get it to work using:

   reload(matplotlib)
   matplotlib.use('Agg')

That suggests that the bug is somehow related to GUI code. As John pointed out, we'll want to very exactly which GUI backend is being used.

I'll have to beat on it some more to see if this is robust.

I saw the error message in this code:

pTk/mTk/win/tkWinDraw.c - metacpan.org

   if(!bitmap) {
    panic("Fail to allocate bitmap\n");
    DeleteDC(dcMem);
       TkWinReleaseDrawableDC(d, dc, &state);
    return;
   }

That seems to suggest that the TkAgg backend (or Tkinter itself) is somehow the problem, assuming Gtk doesn't issue the same message (unlikely).

Thanks. Please let us know what other clues you can collect.

Cheers,
Mike

···

Michael Droettboom wrote:

Can you provide the full traceback for the error? Are there no Python line numbers etc.?

I don't see the string "Fail to allocate bitmap" or "Unable to free colormap..." anywhere in the matplotlib source, so it's hard to say where it's coming from. I suspect they are coming from the GUI framework you are using...

If you put your simple example inside of a loop, does the error eventually occur -- or only within the context of your app? If the latter, we'll need to somehow narrow it down to a specific setting or method that causes the problem.

Also, what backend are you using when it breaks? Just Agg, or one of the Gui+Agg backends?

Cheers,
Mike

Chris Kennedy wrote:

hi,
I get this error when I'm generating numerous .png files using matplotlib 0.9.2 in py2.4 on WinXP
-----------------------------
Fail to allocate bitmap

This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.
Unable to free colormap, palette is still selected.

This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.
-----------------------------

The code is simple:
        import matplotlib
        import matplotlib.pyplot as pylab

        pylabFigure = pylab.figure()
        pylabFigure.clf()
        pylab.rcdefaults()
        pylab.plot(p[0::2], p[1::2], 'b-', linewidth=3)
        pylab.title('Endpointing Plot for '+StepMillName)
        pylab.xlabel('Mill Distance ('+m_unit+')')
        pylab.ylabel('~ Electron response ~' )
        pylab.grid(True)
        pylabFigure.savefig('EPP_'+StepMillName+'.png', facecolor='lightgrey', edgecolor='w')
        pylab.close('all')
        pylabFigure = None

I can put this code in a simple program and generate many images without seeing the allocate bitmap error.

Perhaps it is colliding with something else in my main app. Is there a command that can clear, flush, or unselect the palette and/or colormap?

I don't see the allocate error if I switch the backend to 'SVG', that has it own set of issues though: telling me it can't use, but then generating SVG files anyway.

thanks

--
Michael Droettboom
Science Software Branch
Operations and Engineering Division
Space Telescope Science Institute
Operated by AURA for NASA