8000 py/gc: Support multiple heaps. by aykevl · Pull Request #3533 · micropython/micropython · GitHub
[go: up one dir, main page]

Skip to content

py/gc: Support multiple heaps. #3533

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

Closed
wants to merge 1 commit into from
Closed

Conversation

aykevl
Copy link
Contributor
@aykevl aykevl commented Jan 2, 2018

Enable the addition of heap space at runtime. Advantages:

  • The ESP32 has a fragmented heap so to use all of it the heap must be split.
  • Support a dynamic heap while running on an OS, adding more heap when necessary.

With this code, I managed to extend the MicroPython heap to ~200kB on the ESP32:

MicroPython v1.9.3-239-gd16caf776-dirty on 2018-01-02; ESP32 module with ESP32
Type "help()" for more information.
>>> import micropython
>>> micropython.mem_info(True)
stack: 752 out of 15360
GC: total: 206976, used: 5200, free: 201776
 No. of 1-blocks: 30, 2-blocks: 7, max blk sz: 264, max free sz: 6936
GC area #0 (size 96000), from 3ffb30a0:
00000: h=AhhBMh=DhhhDBBBBAhh===h===Ahh==h==============================
00400: ================================================================
00800: ================================================================
00c00: ================================================================
01000: =========================================h==Bh=ShShhThAh=h=Bh==B
01400: ..h.h=......h=..................................................
       (87 lines all free)
17400: ................................................
GC area #1 (size 110976), from 3ffe4de0:
       (108 lines all free)
1b000: ........................
>>> import gc
>>> gc.mem_free()
201616
>>> 

There appears no way to have one large heap on the ESP32, as the ESP-IDF itself fragments the heap:

I (344) heap_init: Initializing. RAM available for dynamic allocation:
I (347) heap_init: At 3FFAE6E0 len 00001920 (6 KiB): DRAM
I (353) heap_init: At 3FFDCE50 len 000031B0 (12 KiB): DRAM
I (360) heap_init: At 3FFE0440 len 00003BC0 (14 KiB): D/IRAM
I (366) heap_init: At 3FFE4350 len 0001BCB0 (111 KiB): D/IRAM
I (372) heap_init: At 4008FC7C len 00010384 (64 KiB): IRAM

I haven't included the code for the ESP32 yet, but it is very s 8000 imple.

I have tested these changes using #3532 and haven't seen a regression.

typedef struct {
mp_state_mem_area_t *area;
size_t block;
} mp_state_mem_stack_element_t;;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's one semicolon too much

Enable the addition of heap space at runtime. Advantages:
  - The ESP32 has a fragmented heap so to use all of it the heap must be
    split.
  - Support a dynamic heap while running on an OS, adding more heap when
    necessary.
@aykevl
Copy link
Contributor Author
aykevl commented Jan 24, 2018

Replaced by a better PR that supports disabling of multiheap support: #3580.

@aykevl aykevl closed this Jan 24, 2018
@dpgeorge dpgeorge added the py-core Relates to py/ directory in source label Jul 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
py-core Relates to py/ directory in source
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants
0