Can I simply invoke garbage collect and clear the root namespace instead of restarting the process to reinitialize my database?
Almost. The symbol pool, however, will remain uncleared:
$ rlwrap q
KDB+ 2.7 2011.02.16 Copyright © 1993-2011 Kx Systems
q).Q.gc[]
0j / as expected, gc is a no-op
q).Q.w[]
used| 108432
heap| 67108864
peak| 67108864
wmax| 0
mmap| 0
syms| 538
symw| 15638
q)-1000000?`6 / 1 million symbols of length 6
`milgli`igfbag`kaodhb`bafclb`kfhogj`jecpae`kfmohp`lk..
q).Q.w[] used
used| 108592
heap| 67108864
peak| 67108864
wmax| 0
mmap| 0
syms| 1000539 / bumped by a million
symw| 31400168
q).Q.gc[]
0j / no-op again!
q).Q.w[]
used| 108592
heap| 67108864
peak| 67108864
wmax| 0
mmap| 0
syms| 1000539 / remains unchanged
symw| 31400168
q)