Something like this:
This is done using tikz but to hide the technicalities I have defined a macro \MemoryLayout that accepts a coma separated list of x-coordinates/colours/labels so that the image above was produced by:
\MemoryLayout{
12/blue!10/A,
21/orange!20/B,
30/red!30/C,
39/yellow!30/D,
48/green!30/E,
62/white/\relax
}
Use a label of \relax when you do not want a label.
All that this macro does is loop over the input data to draw the picture using standard tikz commands. Here is the full code:
\documentclass[tikz, border=5mm]{standalone}
\usetikzlibrary{decorations.pathreplacing}
\newcommand\MemoryLayout[1]{
\begin{tikzpicture}[scale=0.3]
\draw[thick](0,0)--++(0,3)node[above]{$0$};
\foreach \pt/\col/\lab [remember=\pt as \tp (initially 0)] in {#1} {
\foreach \a in {\tp,...,\pt-1} {
\draw[fill=\col](-\a,0) rectangle ++(-1,2);
}
\draw[thick](-\pt,0)--++(0,3)node[above]{$\pt$};
\if\lab\relax\relax\else
\draw[thick,decorate, decoration={brace,amplitude=4mm}]
(-\tp,-0.2)--node[below=4mm]{\lab} (-\pt,-0.2);
\fi
}
\end{tikzpicture}
}
\begin{document}
\MemoryLayout{
12/blue!10/A,
21/orange!20/B,
30/red!30/C,
39/yellow!30/D,
48/green!30/E,
62/white/\relax
}
\end{document}
To remove the numbers just comment out the two \draw[thick]...; commands.