This sets up a lightweight local memory monitor on macOS using only built-in tools.
It watches practical memory health signals including:
- Swap Used
- Wired Memory
- Compressed Memory
- top memory-consuming processes
Hybrid SPSC Logger: Proof-of-Concept
📌 Overview
This project is a cross-platform, modern C++17 proof-of-concept demonstrating how to implement a high-performance, thread-friendly logging queue using hybrid SPSC (Single Producer Single Consumer) queues. It is designed to be a drop-in backend concept that could eventually integrate with loggers such as g3log, but this demo intentionally avoids any dependency on existing frameworks.
| #include <cxxabi.h> | |
| #include <typeinfo> | |
| void main(){ | |
| int status; | |
| char * producerType = abi::__cxa_demangle(typeid(someType).name(),0,0,&status); | |
| char * consumerType = abi::__cxa_demangle(typeid(someType).name(),0,0,&status); | |
| std::cout << "Producer type: " << producerType << "\n"; | |
| std::cout << "Consumer type: " << consumerType << "\n"; | |
| free(producerType); |
| // Provides a C++11 implementation of a multi-producer, multi-consumer lock-free queue. | |
| // An overview, including benchmark results, is provided here: | |
| // http://moodycamel.com/blog/2014/a-fast-general-purpose-lock-free-queue-for-c++ | |
| // The full design is also described in excruciating detail at: | |
| // http://moodycamel.com/blog/2014/detailed-design-of-a-lock-free-queue | |
| // Simplified BSD license: | |
| // Copyright (c) 2013-2015, Cameron Desrochers. | |
| // All rights reserved. |
| //// to compile: c++ bench.cpp -o bench -Wall -Wshadow -Wextra -pedantic -std=c++11 -pthread -I../include -O3 -fPIC -Ofast -m64 -march=native | |
| // Alternative: c++ bench.cpp -o bench -Wall -Wshadow -Wextra -pedantic -std=c++11 -pthread -I../include -O3 -march=native | |
| // the test code itself is Public domain @ref: Unlicense.org | |
| // made by KjellKod, 2015, first published for testing of g3log at github.com/kjellkod/g3log | |
| // Feel free to share, modify etc with no obligations but also with no guarantees from my part either | |
| // enjoy - Kjell Hedstrom (aka KjellKod) | |
| // |
| // Public domain @ref: Unlicense.org | |
| // made by KjellKod, 2015. Feel free to share, modify etc with no obligations but also with no guarantees from my part either | |
| // enjoy - Kjell Hedstrom (aka KjellKod) | |
| // | |
| // c++ main_worst_case_latench.cpp -fPIC -Ofast -m64 -march=native -Wall -std=c++11 -stdlib=libc++ -Wunused -o g3log-bench -Ig3log/src/ g3log/build/libg3logger.a | |
| // OR: c++ main_worst_case_latench.cpp -O3 -march=native -Wall -std=c++11 -stdlib=libc++ -Wunused -o g3log-bench -Ig3log/src/ g3log/build/libg3logger.a | |
| #include <thread> | |
| #include <vector> | |
| #include <atomic> |
| // c++ thisfile.cpp -fPIC -Ofast -m64 -march=native -Wall -std=c++11 -stdlib=libc++ -Wunused -o g3log-bench -Ig3log/src/ g3log/build/libg3logger.a | |
| // Public domain @ref: Unlicense.org | |
| // made by KjellKod, 2015. Feel free to share, modify etc with no obligations but also with no guarantees from my part either | |
| // enjoy - Kjell Hedstrom (aka KjellKod) | |
| #include <thread> | |
| #include <vector> |
| //// to compile: c++ bench.cpp -o bench -Wall -Wshadow -Wextra -pedantic -std=c++11 -pthread -I../include -O3 -fPIC -Ofast -m64 -march=native | |
| // Alternative: c++ bench.cpp -o bench -Wall -Wshadow -Wextra -pedantic -std=c++11 -pthread -I../include -O3 -march=native | |
| // the test code itself is Public domain @ref: Unlicense.org | |
| // made by KjellKod, 2015, first published for testing of g3log at github.com/kjellkod/g3log | |
| // Feel free to share, modify etc with no obligations but also with no guarantees from my part either | |
| // enjoy - Kjell Hedstrom (aka KjellKod) | |
| // |