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

Manual major GC fails to compact the heap #7368

Closed
vicuna opened this issue Sep 23, 2016 · 2 comments
Closed

Manual major GC fails to compact the heap #7368

vicuna opened this issue Sep 23, 2016 · 2 comments
Milestone

Comments

@vicuna
Copy link

vicuna commented Sep 23, 2016

Original bug ID: 7368
Reporter: amharc
Status: closed (set by @damiendoligez on 2016-09-28T09:28:21Z)
Resolution: fixed
Priority: normal
Severity: minor
Version: 4.03.0
Target version: 4.04.0 +dev / +beta1 / +beta2
Fixed in version: 4.04.0 +dev / +beta1 / +beta2
Category: runtime system and C interface
Monitored by: braibant @gasche

Bug description

When the programmer triggers the major collection manually using either Gc.major () or Gc.full_major (), the decision whether to compact the heap or not is based on a heuristic separate from the usual one. In particular, it does not compact the heap if it consists only of a single chunk. This was fine when the first chunk was never deallocated, but this has no longer been true since #5389: After a heap recompaction occurs, the heap consists of a single chunk, which can be arbitrarily large. If the programmer keeps triggering garbage collection manually, this chunk will not be compacted even if the live set size is small.

The attached program exhibits this behaviour: even though the live set is ca. 8 MB, the heap size is kept at ca. 14 GB.

Steps to reproduce

opam switch 4.03.0
eval opam config env
ocamlopt test.ml -o test
./test

File attachments

@vicuna
Copy link
Author

vicuna commented Sep 23, 2016

Comment author: amharc

cc braibant

@vicuna
Copy link
Author

vicuna commented Sep 28, 2016

Comment author: @damiendoligez

I can't reproduce the problem with your test program because some GC happen during the call to build and trigger the compaction, but I agree with your description of the problem.

Fixed in 4.04 (commit 4ab6b5c).

@vicuna vicuna closed this as completed Sep 28, 2016
@vicuna vicuna added the stdlib label Mar 14, 2019
@vicuna vicuna added this to the 4.04.0 milestone Mar 14, 2019
@vicuna vicuna added the bug label Mar 20, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant