What is mdflagwriter and why does it eat up so much RAM?
/System/Library/Frameworks/CoreServices.framework/Frameworks/Metadata.framework/Versions/A/Support/mdflagwriter is part of Spotlight's indexing. There seems to be a bug present for some people where mdflagwriter uses a considerable amount of RAM, but no canonical fix, apart from reinstalling OS X, or for some people reindexing with sudo mdutil -E /.