In many computer systems, a large portion of the execution time and energy consumption is due to memory accesses. The access time and power consumption of a single access increases with increasing memory size. Therefore, most memory accesses should be made to a small memory. Luckily, most programs exhibit locality, i.e.~only a small subset of all variables (=the working set) is accessed frequently. By keeping the working set of the program in a small memory, the memory bottleneck is diminished. Traditionally, caches are used which track the working set of a program in hardware. In contrast, we present a compiler method which computes the working set of the program. Based on the analysis, a set of different small memories is constructed tailored to the application. Furthermore, the program is augmented so that it explicitly moves the current working set in the small memories. In comparison to caches, no hardware is needed to keep track of the working set, which makes memory accesses more en