Friday, April 5, 2013

Simple OutOfMemoryError profiling with VisualVM

Today I used Java heap profiling to investigate a problem with Scala futures.

  1. Start your Java program with the following options. I used a maximum heap size of 32 megabytes to speed up the error. When an OutOfMemoryError occurs, a heap profile file will be dumped.
    -Xmx32m -XX:+HeapDumpOnOutOfMemoryError
  2. Start VisualVM. On Mac OS 10.8 it is located at the following location:
    /System/Library/Frameworks/JavaVM.framework/Versions/Current/Commands/jvisualvm
  3. Choose File > Load and open the heap profile (hprof) file.
  4. You'll be presented with a summary of class memory usage.
  5. Investigate!

Wednesday, April 3, 2013

Play Framework Git workflow

Fork and clone the repo

  1. Visit https://github.com/playframework/Play20/fork_select to fork the repo.
  2. Clone your fork.
    git clone git@github.com:richdougherty/Play20.git mydir
    cd mydir
    
  3. Track upstream in your fork.
    git remote add upstream https://github.com/playframework/Play20.git
    # http://stackoverflow.com/questions/520650/how-do-you-make-an-existing-git-branch-track-a-remote-branch
    git branch --set-upstream master upstream/master
    

Starting work on a feature branch

git checkout master
git pull
git checkout -b mybranch

Folding commits and rebasing a feature branch

git commit -a
git log # review changes
git rebase -i HEAD~2 # for 2 commits
git checkout master
git pull
git checkout mybranch
git rebase master

Pushing a feature branch

git commit -a
git push origin mybranch

Folding commits and re-pushing feature branch

git commit -a
git log # review changes
git rebase -i HEAD~2 # for 2 commits
git push origin +mybranch

Linking a feature branch to an existing issue

# http://opensoul.org/blog/archives/2012/11/09/convert-a-github-issue-into-a-pull-request/
hub pull-request -i 999 -b playframework/Play20:master -h richdougherty/Play20:mybranch