From Liu Zongyuan's Tang-dynasty 《陆文通墓表》: 其为书,处则充栋宇,出则汗牛马 — 'his books, stored, filled the rafters; carted, made the oxen sweat.'
memory
Think of two scenes: an ox pulling the scrolls sweating from the load (汗牛), and stacks so high they fill the roof beams (充栋). Both are hyperbole for 'a lot of books.'