08-28-25 Lab 1
Valgrind is not natively supported on recent versions of macOS, but it’s possible to run it for C++ memory analysis by using Docker-based solutions or by turning to native Apple tools and compiler sanitizers[1][2][3]. For the most up-to-date and reliable memory testing, using AddressSanitizer or the built-in leaks command is generally preferred on modern macOS[4][5][3][6].
Using Valgrind via Docker on macOS
- Set up a Docker image containing Valgrind and C++ build tools like GCC and G++[2][3].
- Place your source code in a local directory.
- Build the Docker image with:
docker build -t valgrind:1.0 . - Open your terminal in your code directory and start a Valgrind-enabled container with:
docker run -it --name valgrind -v $PWD:/tmp -w /tmp valgrind:1.0 - Within the container, recompile your code (Linux ABI) and then run:
This will print detailed memory-leak reports[2][3].valgrind --leak-check=full ./your_binary
Native macOS Alternatives
- AddressSanitizer (ASan): Compile with Clang/g++ and the
-fsanitize=addressflag:
Leak and memory errors are reported to the terminal on exit[4][5][3][7].clang++ -fsanitize=address -g -o my_program my_program.cpp ./my_program - Apple
leakstool: Run your program, then in a separate terminal use:
or directly:leaks <PID>
for a summary of leaks when the process ends[3][6].leaks --atExit -- ./your_binary
Summary Table
| Method | Setup | Usage | Comments |
|---|---|---|---|
| Valgrind via Docker | Docker install | Rebuild code in Linux container, run with Valgrind | Most detailed, slower[2][3] |
| AddressSanitizer | None (built-in) | Compile with -fsanitize=address, run natively |
Fast, works on Apple Silicon[4][5][7] |
leaks tool |
None (built-in) | Run leaks --atExit -- ./program |
Basic, lightweight[3][6] |
On current versions of macOS, AddressSanitizer or the Apple leaks command offer the fastest and most stable C++ memory testing without the need for Linux containers. Valgrind remains available through Docker if advanced reporting is needed
Digital Logic
When to put transistors in serialized or parallel
- You want to have two way for the signal to be able to pass
- This is a parallel case
Build a NOT out of NANDS
- if you NAND input
with itself it will get the opposite, so essentially NAND with the same input works as a NOT.
Build an AND out of NANDS
- Think of (ab)'' = ab
- NAND inputs
and , then again NAND the this result with itself so that it becomes the opposite in order to yield what an AND would yield.
Build an OR out of NANDS
- NAND each input with itself and then, again NAND these nanded inputs.