linux_jemalloc_helper.cpp 615 B

12345678910111213141516171819202122232425
  1. // This file is part of Desktop App Toolkit,
  2. // a set of libraries for developing nice desktop applications.
  3. //
  4. // For license and copyright information please follow this link:
  5. // https://github.com/desktop-app/legal/blob/master/LEGAL
  6. //
  7. #ifdef __FreeBSD__
  8. #include <malloc_np.h>
  9. #else // __FreeBSD__
  10. #include <jemalloc/jemalloc.h>
  11. #endif // !__FreeBSD__
  12. namespace {
  13. class JemallocInitializer {
  14. public:
  15. JemallocInitializer() {
  16. auto backgroundThread = true;
  17. mallctl("background_thread", nullptr, nullptr, &backgroundThread, sizeof(bool));
  18. }
  19. };
  20. static const JemallocInitializer initializer;
  21. } // namespace