Move closeEntryCache a EntryCache member function
Copmute the trace cache size dynamically

We use the LOAD_FACTOR * memory_size as the entry cache size, instead of
the static 256 MB.
Only munmap the entry cache when closeEntryCache

We previously call the flushCache() when close the entry cache for
ateixt(). Actually we don't need to mmap again for the following usage
since we're exiting the whole program.
Move the mmap() code to a common function

This can remove the redundant code. However, we should manully msync and
munmap first before calling mapCache() when the cache is full.
Truncate the trace file to the actual size

We rely on the fileOffset and the remaining cache to truncate the trace
file. This can greatly save space if we use large cache size.