Resource Leakage

Note that VLF-ONE has a similar checking facility, see Major Object Leakages Checked in Developer Mode.

A common resource utilization issue encountered in Windows applications is that when you close a window not all of the resources associated with it are freed up for reuse. This is called 'resource leakage' and if left unchecked it may eventually cause your application to fail or act unpredictably. To help you in this area the VLF includes a simple diagnostic tool to track some resource leakage at a high level.

These facilities are only activated when you use the VLF as a designer.

If you open and close a secondary Framework window and see a message like the example below, it indicates a resource leakage detected by the VLF:  



This message is saying that a VL component (in this case a command handler instance named DF_DET1) was not destroyed when the window was closed.


In other words, DF_DET1 has 'leaked' resources. You should investigate the cause of this and try to prevent it. If you can't work out why this message is being displayed you should consult your Visual LANSA mentor for VL application design advice.


In VLF applications of simple to medium complexity you are unlikely to see this message. However as the sophistication of your VLF and VL application components increases you may encounter this message.  


A common cause of this message is what is called a 'circular reference'. This is where one VL component (say, a command handler 'A') contains a reference to some other object (say, a reusable part named 'B') which itself contains a reference back to command handler 'A'.


The circular reference path may be even more complex. Component 'A' might refer to 'B' which refers to 'C' which refers to 'D' which refers back to 'A'. This is a much longer path, but it is still circular in nature.


Some rough guidelines for avoiding circular references:



In other words, imagine you are an object instance called 'A' and that other objects store references to you in their variables or collections. If you want 'A' to be destroyed, then you need to make sure all referencing objects drop all their references to 'A' first. Object 'A' will not be destroyed as long as any object holds a single reference to 'A.

Important Disclaimer: This VLF facility is a diagnostic feature. It only tracks resource leakage in objects that are 'known' to the VLF runtime environment. As you create more sophisticated VLF applications they could in turn create and destroy many objects that the VLF runtime does not know about and therefore cannot track or report on. Just because you do not see the preceding message box it does not mean that your application is not leaking resources.