This part of your code looks okay. It's possible that you have either circular references between objects, or a problem with closures. Problems with closures under Apache::Registry happen when you have a lexical variable declared outside the scope of a subroutine that uses it. This code above doesn't have that problem, but your real code might.