Addign memory logging before and after merging trivial boundaries