Hi all, does anybody knows if deleting variables that are not used in codeunit or other objects increases performance? If you declare a variable in a codeunit, when exactly the parser allocates the memory for that variable? When you run the object or when the variable is used for the first time? Thanks Marco
If I remember correct it is only created when it is used, but I am not sure. You can test it with a automation control that uses very much memory.
I have wondered the same question. If you declare a bunch of tables, does Navision open them? At the very least, even if there is no performance gain, you can unclutter the code a little bit. See this tool available which I have used many times to find those unused variables at mibuso called the Unused Variables Tool: http://www.mibuso.com/dlinfo.asp?FileID=537
Even if it did it feels to me that the performance gain would be marginal. All it is is some memory reserved for the variable, so you’d have to have MANY unused variables for it to slow down. It’s always a good idea to keep your code clean of course. I would be reluctant to remove variables that are part of commented out code, but otherwise unused variables is just clutter.
What would the performance gain be if we’d remove all the comment from the code ??? [:D]
To remove all the unused variables in your code, just compile the objects, and the Variable sthat are not used will have no tick box next to them, so you can delete them. OOPS! I forgot, that great feature was actually REMOVED from Navision 10 years ago. [:(!] [:(!] [:(!]
I found a tool in MIBUSO doing analysis on unused variables. In fact it will make life easier (especially when doing an upgrade/merge) if you do not have loads of unused variables. I do not think that it has much impact on the speed (I mean the variables (objects) are getting initialized (to make sure that a declared integer contains zero and nothing else, but the time consumed for that (in fact just a MOV in assembler) does not make much difference.