Allocation Memory Error

Hello there, when trying to code a cool logo onto the brains screen, without using PROS, I got this error in the console: “MemoryError: memory allocation failed, allocating 37312 bytes” I have a MiniSD card that I can use to allocate the 37 Kb, but how would I do this? Also to complicate things further, I’m using Python.

If you have any suggestions of how to solve this problem as well as ideas to print images, other than just use pros, it would be kindly appreciated. Thanks!

You don’t have to use PROS, VEXcode C++ can display images.

Are you using VEXcode Python or RobotMesh Python ?
If it’s VEXcode, send me or post the code so I can see what’s happening, it should be able to easily handle that size of allocation.

4 Likes

Hey, thanks for the speedy reply. I’ll look into using c++, is that with the Pro version, or just VEXCode v5?

Also, the code is in VEXPython and is just:
brain.screen.set_fill_color(Color.WHITE)
brain.screen.set_cursor(0,0)
brain.screen.draw_rectangle(0, 0, 479, 239)
brain.screen.set_pen_color(Color.BLACK)
And then 12138 lines of printing pixels at a location on the brain, resulting in a black and white logo.

This is quite a dumb idea to do, but I thought that it would look pretty cool if it would work. If this is stupid, please let me know, I dont want to do something really dumb, you know. My bot is in python though, so finding some work-around would be preferable. But if not, thats ok too. Thanks for the help

ok, well, that’s a bit, shall we say, unusual.

send me the project via DM, I would like to see why it doesn’t work. 12000+ lines of source code may just be too much for the V5 to compile. Why not just read the logo from the SD Card ?

6 Likes

Just to close this topic.
12000 lines of

brain.screen.draw_pixel(51, 90)

was too much for the V5, I set the Python heap at 1MB, it could have been much larger but that would have slowed garbage collection, I was not expecting a program with 12000 calls to draw_pixel.
Moving the data into an array works.

image = [ (51, 90),
          (52, 90),
          (53, 90),
          (54, 90),
          (55, 90),

          many more entries

          (330, 145),
          (331, 145),
          (332, 145),
          (333, 145),
          (334, 145) ]

for p in image:
  brain.screen.draw_pixel(p[0], p[1])

work ok, but not something I would recommend.

use

brain.screen.draw_image_from_file("test_24.bmp", 0, 0)

and pull the image from SD card

7 Likes

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.