Arrays are the ubiquitous organization for indexed data. Throughout programming language evolution, implementations have laid out arrays contiguously in memory. This layout is problematic in space and time. It causes heap fragmentation, garbage collection pauses in proportion to array size, and wasted memory for sparse and over-provisioned arrays. Because of array virtualization in managed languages, an array layout that consists of indirection pointers to fixed-size discontiguous memory blocks can mitigate these problems transparently. This design however incurs significant overhead, but is justified when real-time deadlines and space constraints trump performance.This paper proposes z-rays, a discontiguous array design with flexibility and efficiency. A z-ray has a spine with indirection pointers to fixed-size memory blocks called arraylets, and uses five optimizations: (1) inlining the first N array bytes into the spine, (2) lazy allocation, (3) zero compression, (4) fast array copy, and (5) arraylet copy-on-write. Whereas discontiguous arrays in prior work improve responsiveness and space efficiency, z-rays combine time efficiency and flexibility. On average, the best z-ray configuration performs within 12.7% of an unmodified Java Virtual Machine on 19 benchmarks, whereas previous designs have two to three times higher overheads. Furthermore, language implementers can configure z-ray optimizations for various design goals. This combination of performance and flexibility creates a better building block for past and future array optimization. on discontiguous array optimization choices. Our experimental results on 19 SPEC and DaCapo Java benchmarks show that our best z-ray configuration adds an average of 12.7% overhead, including a reduction in garbage collection cost of 11.3% due to reduced space consumption. In contrast, we show that previously proposed designs have overheads two to three times higher than z-rays.Z-rays are thus immediately applicable to discontiguous arrays in embedded and real-time systems, since they improve flexibility, space efficiency, and add time efficiency. Since the largest object size determines heap fragmentation and pause times, and first-N increases it by N, some system-specific tuning may be necessary to achieve particular space and time design goals. We believe zrays may also help to ameliorate challenges in general-purpose multicore hardware trends. For example, multicore hardware is becoming more memory-bandwidth limited because the number of processors is growing much faster than memory size. Lazy allocation and copy-on-write eliminate unnecessary, voluminous, and bursty write traffic that would otherwise slow the entire system down. Z-rays not only make discontiguous arrays more appealing for real-time virtual machines, but also make them feasible for general-purpose systems.Our results demonstrate that z-rays achieve both performance and flexibility, making them an attractive building block for language implementation on current and future architectures.