32

I am currently unable to push changes I've made to a project to GitHub because it keeps finding these massive (~300MB) files called "java_pid(random numbers).hprof". I have no idea where they're coming from. Google searches aren't coming up with anything helpful - everyone else is asking about how to use them, and with regard to Eclipse, and I'm using Android Studio, and I don't care what's in them, I just want them gone.

Please help!

trincot
  • 317,000
  • 35
  • 244
  • 286
Andrew Torr
  • 1,057
  • 3
  • 13
  • 26
  • 1
    I'm not finding the word "java_pid" in the Android platform source code -- maybe it's some app calling [`Debug.dumpHprofData()`](http://developer.android.com/reference/android/os/Debug.html#dumpHprofData%28java.lang.String%29)? Where are the created hprof files located? Can you see the creator if you do an `adb shell ls -l` on the file(s)? – Snild Dolkow Oct 28 '15 at 20:07
  • It has something to do with memory leaks, I think it dumps the excess into these files. The files are in the main project folder, where the .git folder is. I tried deleting them, replacing them with tiny files with the same name, removing them from my commit ( git rm *.hprof ), resetting them ( git reset --soft HEAD^ *.hprof ), and adding them to my .gitignore. It still thinks the files are there. If there was a memory issue in the app, it's apparently gone, because the original files haven't re-appeared. – Andrew Torr Oct 29 '15 at 14:17
  • Oh, I misread your question -- I thought these files were on the Android device, not your computer. Well then, your question is really a git question. The `.gitignore` file only affects files that haven't been added to the index (i.e. have not been `git add`ed or committed). – Snild Dolkow Oct 29 '15 at 17:52
  • 2
    `git rm *.hprof` followed by a `git commit --amend` should remove them from the index. This must be done on the commit that originally added them -- if your "bad" commit is not your latest, you can just amend. Otherwise, do a `git rebase -i` to go back to the "bad" commit first (choose "edit" for that commit). For a more detailed explanation, I'd recommend the "Interactive rebase" part of [this answer](http://stackoverflow.com/a/2158271/4811803). – Snild Dolkow Oct 29 '15 at 17:57
  • Possible duplicate of [How to remove/delete a large file from commit history in Git repository?](http://stackoverflow.com/questions/2100907/how-to-remove-delete-a-large-file-from-commit-history-in-git-repository) – Snild Dolkow Oct 29 '15 at 17:58
  • @AndrewTorr did you find out what was hapenning here? I'm having the same issue. – Fábio Carballo Jan 21 '16 at 19:07
  • @FábioCarballo No, we've tried just about everything. In the end we just created another branch and copied everything over manually. – Andrew Torr Jan 21 '16 at 20:13

7 Answers7

32

When you're monitoring memory usage in the Memory Monitor included in Android Monitor you can, at the same time, dump a snapshot of the Java heap to an Android-specific Heap/CPU Profiling (HPROF) file. The HPROF Viewer displays classes, instances of each class, and a reference tree to help you track memory usage and find memory leaks. HPROF is a binary heap dump format originally supported by J2SE.

You can delete it.

https://developer.android.com/studio/profile/am-hprof.html

UmAnusorn
  • 10,420
  • 10
  • 72
  • 100
14

I stumbled on this problem recently and found that BFG helped.

BFG can be installed using Homebrew in macOS. Then I run:

bfg --strip-blobs-bigger-than 100M /git_folder/

…to remove any file bigger than 100MB on git history then run:

git reflog expire --expire=now --all && git gc --prune=now --aggressive

Finally I push and everything works.

Giacomo1968
  • 25,759
  • 11
  • 71
  • 103
deathemperor
  • 846
  • 9
  • 17
1

check your log, find out where you might have accidentally committed that file and get the hash from it using,

git log --name-only

copy the first 7 characters from the log history use,

git checkout 7_character_string android/java_pid0000.hprof

java_pid0000.hprof -> this should match your file name which will show up after push failed.

deathemperor
  • 846
  • 9
  • 17
Alish Giri
  • 1,855
  • 18
  • 21
1

It's just heap dump. I was lucky enough to catch early. Removed large files and do git commit --amend to get rid of it.

0

This tripped me up, and combinations of deleting and gitignore was not getting rid of it. End up using a combo of git log --name-only to find the commit and then reset soft back 14 commits or so git reset --soft HEAD~14 back to the commit before to remove it add to gitignore and then commit and get back to work.

Nick Foden
  • 1,108
  • 11
  • 12
0

I had the same problem,I wasnt able to push my changes to git,when i checked git status it kept on giving me untracked files ,when i try to do git stash it didnt work, they kept on appearing again, so I went to visual studio,and found the untracked *.hprof files and deleted them from there,now I am able to push my changes to git.

-3

maybe jdk is not correct.

android studio - file - project structure - sdk location - jdk location - use embedded jdk

can solve your problem