I made my first bread today from scratch. The recipe is very simple:
I am currently working on a small Python project with a relatively large memory footprint. I wanted to
analyze the usage in detail and realized that I wasn’t aware of any good Python memory profiler. After
some searching I found the builtin package tracemalloc
(Trace memory allocation). Especially interesting to me is the capability to take snapshots at different
points in time and then compare the delta between those snaphots. The following snippet illustrates this.
import numpy
import tracemalloc
tracemalloc.start()
snapshot_before = tracemalloc.take_snapshot()
array = numpy.zeros((100, 100))
array2 = numpy.random.rand(1_000_000, 1_000)
print(array2.dtype)
array3 = array2.astype(numpy.float16)
snapshot_after = tracemalloc.take_snapshot()
stats = snapshot_after.compare_to(snapshot_before, 'lineno')
for s in stats[:10]:
print(s)
print(tracemalloc.get_traced_memory())
pip3 install memray
# Run application and save snapshots
memray run my_app.py
# Display snapshots
memray flamegraph memray-test.py.94623.bin
I recently updated this blog to Ruby 3.2.0 which was released on Dec 25, 2022. I expected this to be a minor update since I came from Ruby 3.1.2. However, I ran into some problems that I had to solve.
I never liked having the router in full display in the living room. I routed the fiber connection into a closet in our hallway with the plan on making this a “tech closet”. I had to route electricity to the closet and install some shelves. The goal was to have a space for the router, my printer (that I only use ocassionally), some other hardware like a Raspberry Pi and to be able to charge a Dyson vacuum cleaner.