directory: a temporary solution for debugging reference leaks.

Do not use reference counting when debug is enabled, so valgrind can
correctly detect memory leaks.
db, simple_db: remove a redundant db_lock