At Sun, 26 Aug 2018 09:55:25 -0700 (PDT), Jonathan Simpson wrote:
> Then if I run (collect-garbage 'major), 
> current-memory-use reports only about 300MB in use, but the VIRT/RES values 
> reported by top do not change. The VIRT/RES values don't actually decrease 
> until I unlink the variable pointing to the data structure and re-run 
> collect-garbage. At that point top reports about 300MB when according to 
> current-memory-use only about 80MB of memory is reachable.
> 
> So, it seems that the memory used by Linux is lagging behind Racket's 
> garbage collection. Is there an explanation for this? I need a way to fully 
> release resources back to the OS as quickly as possible.

I'm not sure exactly how it maps to what you're seeing, but here are
some things I can report.

Racket's memory manager does not immediately release pages back to the
OS (i.e., unmap them) after a GC. In its current configuration, the GC
releases a page at the beginning of a major GC only if the page was
unused at the *start* of the previous GC. So, there's roughly a lag of
2 GCs to unmap a page that becomes unused as a result of a GC. That
policy reduces back-and-forth with the OS on page allocation, which can
be relatively costly.

Then again, at the end of a GC, if there are more than 4 times as many
mapped pages as currently in use, then all unused pages are immediately
released. That rule is an attempt to keep actual use and mapped pages
from getting too far out of sync.

Racket doesn't reserve pages without mapping them, so you don't need to
worry about that potential difference.

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to