‎2018 Jun 08 11:43 AM
Hello,
I prefer to define constants as attributes in a class interface for cross program usage. Now, someone said, global constants have an negative performance issue. Argumentation is something like "The constant value needs to be copied from global stack to local program stack".
Looking at 'Declaration of Data Types and Constants' (SAP ABAP docu) I think it should be ok like I usual do.
Can you confirm performance issues with global ABAP OO constants? Is this a real issue which the end user will realize at a normal transcation? Or is this more a academic topic?
Thanks in advance
‎2018 Jun 09 4:41 AM
Use Interface Constants instead of Class. There is no performance issues with global constant.
‎2018 Jun 08 12:47 PM
No, there aren't performance issues with global constants. #fairytale
‎2018 Jun 08 2:19 PM
This is possibly an issue with loading a static class into the internal session memory, which - unlike instances - is not unloaded by the garbage collector. I think this may be what your colleague might be referring to.
This is one argument for using interface vs class constants, as interfaces contain no executable code and interface constants are (probably) evaluated at compile time. Personally I use interface constants as well for this reason.
‎2018 Jun 08 5:00 PM
‎2018 Jun 08 9:20 PM
...which is exactly the bit I'm unsure about: Since interfaces have no executable code, are they considered bytecode or processed in their entirety at compile-time for scenarios such as this? It's theoretically possible, but, ABAP being ABAP, theory means little 🙂
‎2018 Jun 08 11:04 PM
I guess documentation is due for another update. 🙂
But seriously - are we even talking any significant potential performance impact here?
‎2018 Jun 09 7:06 AM
Could have a significant impact for large scale compute-intensive applications such as cosmological dark matter distribution modelling, or playing chess against another computer.
In other words, mostly academic.
‎2018 Jun 10 2:45 PM
PXA also buffers shared resources like the values of constants.
‎2018 Jun 09 4:41 AM
Use Interface Constants instead of Class. There is no performance issues with global constant.
‎2018 Jun 10 2:47 PM
But classes allow unit tests. Can make sense even for constants (checking values against external ressources).