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

malloc으로 몇 바이트까지 할당가능한 것인지 질문드립니다 #13

Open
Jukim2 opened this issue Apr 19, 2024 · 1 comment
Labels
solved Question solved

Comments

@Jukim2
Copy link

Jukim2 commented Apr 19, 2024

처음에 3210241024 = 33,554,432개를 ds_allocate에 넘겨서
ds_heap_end - ds_heap_start = 33,554,432이 되게 값을 주는 것으로 알고있습니다.

memmgr로 넘어와서, 양 sentinel을 빼게 되면 heap_start와 heap_end사이에는 총 33,554,432 - 32 * 2 = 33,554,368바이트가 존재하게됩니다.

그러면 header와 footer를 뻈을 때 33554368 - 8 * 2 = 33,554,352바이트까지 할당이 가능할 것 같은데 레퍼런스 프로그램에서 그렇게되지않아 잘못 생각한 부분이 있는지 궁금하여 질문드립니다.

@kwonsw055
Copy link
Collaborator

  1. heap_startheap_end는 32 byte aligned 된 주소여야 한다는 점
  2. dataseg에서 ds_sbrk 호출 시 ds_heap_brkds_heap_end와 같을 수 없다는 점
    등으로 인해 실제 가능한 malloc 크기는 줄어들 수 있습니다.

@kwonsw055 kwonsw055 added the solved Question solved label Apr 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
solved Question solved
Development

No branches or pull requests

2 participants