Call malloc_trim(0) on Linux

This commit is contained in:
Jacob Dufault 2017-08-17 11:02:47 -07:00
parent 2328141d98
commit 3f44307268
4 changed files with 16 additions and 1 deletions

View File

@ -2623,6 +2623,10 @@ void QueryDbMain(const std::string& bin_name, Config* config, MultiQueueWaiter*
config, &db, waiter, &queue,
&project, &file_consumer_shared, &import_manager, &timestamp_manager, &working_files,
&clang_complete, &include_complete, global_code_complete_cache.get(), non_global_code_complete_cache.get(), signature_cache.get());
// Cleanup and free any unused memory.
FreeUnusedMemory();
if (!did_work) {
waiter->Wait({
IpcManager::instance()->threaded_queue_for_server_.get(),

View File

@ -50,4 +50,7 @@ void CopyFileTo(const std::string& destination, const std::string& source);
bool IsSymLink(const std::string& path);
// Returns any clang arguments that are specific to the current platform.
std::vector<std::string> GetPlatformClangArguments();
std::vector<std::string> GetPlatformClangArguments();
// Free any unused memory and return it to the system.
void FreeUnusedMemory();

View File

@ -5,6 +5,7 @@
#include <loguru.hpp>
#include <malloc.h>
#include <cassert>
#include <string>
#include <pthread.h>
@ -247,4 +248,8 @@ std::vector<std::string> GetPlatformClangArguments() {
}
#undef CHECKED
void FreeUnusedMemory() {
malloc_trim(0);
}
#endif

View File

@ -226,4 +226,7 @@ std::vector<std::string> GetPlatformClangArguments() {
"-fdelayed-template-parsing"
};
}
void FreeUnusedMemory() {}
#endif