We present two novel algorithms for constructing spatial hierarchies on GPUs. The first is for kd-trees that automatically balances between the level of parallelism and total memory usage by using a novel PBFS (partial breadth-first search) construction scheme. With this PBFS construction scheme, peak memory consumption can be efficiently controlled without costly CPU-GPU data transfer. We also develop memory allocation strategies to effectively limit memory fragmentation. The resulting algorithm scales well with GPU memory and constructs kd-trees of models with millions of triangles at interactive rates on GPUs with 1GB memory. Compared with existing algorithms, our algorithm is an order of magnitude more scalable for a given GPU memory bound. The second algorithm is for out-of-core BVH (bounding volume hierarchy) construction for very large scenes based on the PBFS construction order. At each iteration, all constructed nodes are dumped to the CPU memory, and the GPU memory is fre...