Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.Sign up
tmpfs not properly freeing memory after rsync #133
I found an issue while performing an rsync into a gVisor container on App Engine Standard, which when tested locally against gVisor, elicits the same behavior.
With /tmp mounted as tmpfs inside the container, after rsyncing the same files over and over again, the memory usage goes up and up, never to be freed (until the container is killed for using to much memory, as is the case for App Engine).
To test this out, first create a 100MB file locally:
Check the free memory status of the container:
container created from guide at , command to run it 
Then rsync it over to a gVisor container running an SSH server:
If we do an
And if we
As shown, the 200 MB is still showing under "shared" even after the file is gone.
The memory doesn't look like it is being held by any processes:
Running the same thing against a standard docker container (not runsc/gVisor) performs how you'd expect, not showing this behavior:
 : https://docs.docker.com/engine/examples/running_ssh_service/
Debug data is too big to upload, so please find it at  (GCS, requestor pays).
Installation was the latest nightly installer as per instructions at .
Thanks for the detailed report! I suspect we have a reference counting issue that is causing us to keep the file in memory.
I can reproduce the issue with this script:
#!/bin/bash echo "before" free -m echo echo "test1" dd if=/dev/zero of=/tmp/test1 bs=1M count=100 free -m echo echo "test2" dd if=/dev/zero of=/tmp/test2 bs=1M count=100 free -m echo echo "move test2 to test1" mv /tmp/test2 /tmp/test1 free -m echo echo "remove test1" rm /tmp/test1 free -m echo echo "remove test2" rm /tmp/test2 free -m
https://gvisor-review.googlesource.com/c/gvisor/+/14901 should fix this issue.