The function itself and variables seem ok to me. But what caught my eye is that you use oApplication = Object. I have no idea whatsoever how the deprecated objects work or if they're still supported. You didn't include the essential for the problem (memory leak) which is use of that oApplication.
Bookmarks