Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MaixBit setting heap size with utils.gc_heap_size() no longer works #490

Open
Lawrence-RedFern opened this issue Aug 18, 2023 · 1 comment

Comments

@Lawrence-RedFern
Copy link

Describe the bug
I had been running a script on a machine which would identify an image. Without changing anything, the script starting reporting

MemoryError: Out of normal MicroPython Heap Memory! Please reduce the resolution of the image you are running this algorithm on to bypass this issue!

when trying to execute the line img = image.Image(sd_image_path).resize(224,224)

at the start of the script I have the line utils.gc_heap_size(1500000) to ensure there is space in the GC ram to resize the image. Previously I had no issue with this, and the images that I have been testing with have not increased in file size or resolution.

When running the lines after my call to utils.gc_heap_size(1500000)

print("kpu.memtest(): " + str(kpu.memtest()))
print("utils.heap_free(): " + str(utils.heap_free()))
print("utils.gc_heap_size(): " + str(utils.gc_heap_size()))
print("gc.mem_alloc(): " + str(gc.mem_alloc()))
print("gc.mem_free(): " + str(gc.mem_free()))

The board now prints out

###free gc heap memory : 478 KB
###free sys heap memory: 1876 KB
utils.heap_free(): 1921024
utils.gc_heap_size(): 524288
gc.mem_alloc(): 16896
gc.mem_free(): 501120

which shows that my call to utils.gc_heap_size(1500000) is not working.

If I run the exact same script on a healthy board, the same script returns what I'd expect which is

###free gc heap memory : 1418 KB
###free sys heap memory: 924 KB
utils.heap_free(): 946176
utils.gc_heap_size(): 1500000 <- what I expect
gc.mem_alloc(): 15904
gc.mem_free(): 1466592

I'm wondering if there is any solution to this bug? I've tried running the lines

gc.enable()
gc.collect()
machine.reset

and also deiniting the .kmodel I have been using a = kpu.deinit(task), all to no avail on the bugged board. The healthy board does not have any issues.

Please complete the following information

  • IDE version: [MaixPy IDE 0.2.5]
  • Firmware version: [maixpy_v0.6.2_84_g8fcd84a58_openmv_kmodel_v4_with_ide_support]
  • Board: [MaixBit]
  • OS: [Windows]
@Lawrence-RedFern
Copy link
Author

Using Kflash to erase the whole board has fixed the bugged board, it now returns

###free gc heap memory : 1418 KB
###free sys heap memory: 924 KB
kpu.memtest(): None
utils.heap_free(): 946176
utils.gc_heap_size(): 1500000
gc.mem_alloc(): 15904
gc.mem_free(): 1466592

but I would still like to know how this could have happened in the first place. If anyone has encountered this issue before please let me know :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant