Created
April 28, 2016 00:22
-
-
Save mrh1997/9925bbb8e5f7b0ab8c88189d562ad42d to your computer and use it in GitHub Desktop.
Script to reproduce https://github.com/libgit2/pygit2/issues/625 by running ``vagrant up`` and ``vagrant ssh -- reproduce_memleak.py``
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pygit2 | |
import os | |
import subprocess | |
SAMPLE_REPO_DIR = '/home/vagrant/libgit2' | |
sampleRepo = pygit2.Repository(SAMPLE_REPO_DIR) | |
master = sampleRepo.revparse_single('master') | |
diffCommit = master | |
for srcCommit in sampleRepo.walk(master.id, pygit2.GIT_SORT_REVERSE): | |
topCmd = ['top', '-b', '-n', '1', '-p', str(os.getpid())] | |
usedMemory = subprocess.check_output(topCmd).splitlines()[-1][24:30] | |
print "Currently Used Memory:", usedMemory, "kB" | |
# Also I call only this function, memory usage will grow and grow | |
sampleRepo.diff(diffCommit, diffCommit) | |
diffCommit = srcCommit |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Vagrant.configure(2) do |config| | |
config.vm.box = "ubuntu/trusty32" | |
config.vm.provision "shell", inline: <<-SHELL | |
# install components required for building libgit2 / pygit2 | |
sudo apt-get install -y git | |
sudo apt-get install -y cmake | |
sudo apt-get install -y --fix-missing python-pip # ignore missing server | |
sudo apt-get install -y python-dev | |
sudo apt-get install -y python-cffi | |
# build and install libgit2 | |
cd /home/vagrant | |
sudo -u vagrant git clone https://github.com/libgit2/libgit2.git | |
cd libgit2 | |
sudo -u vagrant git checkout v0.24.1 | |
sudo -u vagrant mkdir build | |
cd build | |
sudo -u vagrant cmake .. | |
sudo -u vagrant make | |
sudo make install | |
sudo ldconfig | |
# install pygit2 | |
sudo pip install pygit2==0.24.0 | |
SHELL | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment