Showing posts with label debug. Show all posts
Showing posts with label debug. Show all posts

Tuesday, January 29, 2013

Analyze memory fragmentation with VMMap

VMMap is a process virtual and physical memory analysis utility. It shows a breakdown of a process's committed virtual memory types as well as the amount of physical memory (working set) assigned by the operating system to those types. Besides graphical representations of memory usage, VMMap also shows summary information and a detailed process memory map

 

If you have an application that runs out of memory and you only see 800MB of memory used you probably have fragmentation problems. You can use VMMap to see how the memory is allocated. If you use VirtualAlloc for less than 64 KB you will generate unusable memory regions. This is because the address must be aligned to 64KB. By allocating 10 chunks of 1KB you will have 10KB of used memory and 630KB of unusable memory. If you have 32-bit application you may run out of memory (you only have 2 GB of virtual address space available).

References:
http://technet.microsoft.com/en-us/sysinternals/dd535533.aspx

Sunday, January 27, 2013

git bisect

The bisect command does a binary search through the commit history in order to help you identify which commit introduced an issue.
To begin a git bisect, the first command is:
git bisect start
After this, you must tell git a bad and a good commit:
git bisect bad # or git bisect bad HEAD
git bisect good HEAD~10
In this example, the HEAD is broken and that 10 commits before the HEAD is a good point.
Git will then begin the binary search and ask you about the state (good/bad) of the current revision.
You tell this by running:
git bisect good
or
git bisect bad
At the end, git will tell you the commit that introduced the issue.
In order to stop the git bisect you must run:
git bisect reset
You should run this command after finishing the search.

Finally, if you have a script that returns 0 if a commit is good and a non-zero result otherwise, you can find out the bad commit in 2 lines:
git bisect HEAD last_good_revision
git bisect run ./script.sh

References:
http://git-scm.com/book/en/Git-Tools-Debugging-with-Git