Classes, Static Methods, or Instance Methods - Memory Consumption and Executable Size in Compiled Languages?

I keep wondering about this to try to improve the performance and size of my Flex swfs, how do class methods and static methods or instances affect the performance and final size of the compiled "executable"? Thinking of how you could apply something like HAML and Sass to Flex ...

Let's say I create a very large admin interface with a lot of components and views, and each of these components has a Skin object to it (thinking about Spark Skinning Architecture for Flex ).

Now I want to add 10 different effects for each skin (let's say there are 100 components on the screen, so there are 1000 instances of the effects). Is it better:

  • Each effect has a class (BlurEffect, GlowEffect ...) and add these 10 to the skin.
  • All effects have instance methods in one larger class, say, “MultiEffect.as”, and add one class to the multiEffect.glow() referenced as multiEffect.glow() .
  • All effects have static methods in the same Singleton-esque EffectManager.as class and simply reference effects on the skin through EffectManager.glow(this) .

So,

  • Several classes of effects for each skin, vs.
  • One effect class for each skin with instance methods, vs.
  • Class of one effect globally with static methods

How do these things affect memory and executable size (swf size in this example)? I know that classes are OO's best methods, and that static methods are slower than instance methods, and that singletones should be avoided, so this is not about performance. More on memory (in some cases, it would be a little better) and file size.

+4
source share
1 answer

Could not find such information for Flex, but for Java (which should not be too different), the overhead of creating objects is only 8 bytes of memory.

This means that if we are talking about 1000 copies, the overhead for using objects for each instance is no more than 8 KB - insignificant. If 100 times bigger, it's still 800K, which is still nothing.

So, repeating the previous answers, select the option that will give you the best design.

Oh, and the difference in the resulting file size is almost nothing.

0
source

Source: https://habr.com/ru/post/1301660/


All Articles