Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Fail to allocate bitmap
#1
i am getting error message "Fail to Allocate Bitmap", i need add more than one lakh images of 16X16 Pixels in to canvas. please help. it gives error after loading 4989 bitmaps.

rowimage = {}
x= 1
for row in range(135):
for col in range(448):
filename = str((col) * 16) + ',' + str((row) * 16)
if filename in images:
rowimage[filename] = PhotoImage(
file="F:/Symbols/" + images[filename])
canvas.create_image(((col)*16) + 8, ((row)*16) + 8, image=rowimage[filename],
anchor='center')
x = x + 1
print(x)
Reply
#2
Can you tell as a bit more about your program... which modules are you using? It would be extremely helpful if you posted some code and complete error messages (both in proper tags, see help here).
Problem could be a memory leak issue, since you seem to be loading a lot of data. It can happen with tkinter and maybe even matplotlib.
Reply
#3
thank you,

this is the error message i am getting

Error:
Fail to allocate bitmap Process finished with exit code -2147483645
please see below is my code

from tkinter import *

canvas_width = 448 * 16
canvas_height = 135 * 16

master = Tk()

canvas = Canvas(master,
width=canvas_width,
height=canvas_height)
canvas.pack()

images = {'0,992' : '106414.png',
Reply
#4
I would guess it is a memory leak due to many png files you are allocating. You can do a quick check by editing the code so that you include just a few images for a test, and see if that works.
Reply
#5
Yes, it is working upto 4989 images after that it is giving error message. i need to load more than one lakh png images. please hlep
Reply
#6
Do you load and unload the module? What happens to memory consumption when you load and unload, do you see memory linearly increasing? Can you check? And also, it may be that, when you load all those images they remain in the memory because you haven't unloaded then and therefore you have no headroom for anymore images
Reply
#7
how to unload the memory
Reply
#8
What are you trying to do?
"As they say in Mexico 'dosvidaniya'. That makes two vidaniyas."
https://freedns.afraid.org
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Why does [root.destroy, exit()]) fail after pyinstaller? Rpi Edward_ 4 616 Oct-18-2023, 11:09 PM
Last Post: Edward_
  How to calculated how many fail in each site(s) in csv files SamLiu 4 1,285 Sep-26-2022, 06:28 AM
Last Post: SamLiu
  Imports that work with Python 3.8 fail with 3.9 and 3.10 4slam 1 2,587 Mar-11-2022, 01:50 PM
Last Post: snippsat
  [SOLVED] Why does regex fail cleaning line? Winfried 5 2,455 Aug-22-2021, 06:59 PM
Last Post: Winfried
  scraping video src fail jacklee26 5 3,501 Jul-11-2021, 09:38 AM
Last Post: snippsat
  Unable to allocate specific memory VirtualDreamer 1 2,476 Jul-13-2019, 07:04 AM
Last Post: Gribouillis
  Create bitmap image for my exe atlass218 5 3,627 Nov-04-2018, 06:24 AM
Last Post: atlass218
  fail to upgrade pygobject jiapei100 0 3,077 Aug-16-2018, 10:32 AM
Last Post: jiapei100

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020