Using ColdFusion memory for components

I create a site using VMC and using beans to transfer data from the model to the controller / view.

I plan to implement some basic and very simple caching that will store beans in a simple structure if they have not changed (as we grow in use, we will implement the best caching system around version 1.3).

So, the question is what is going on in our bean.

One type of bean will contain only basic data and will rely on some external service to do the rest of the work (referring to the DAO to get the request, parsing the request to load the bean values). This is "bean anemia", as an employee repeatedly informed me :-).

Another type of bean will be more autonomous. He would know where the DAO would go so directly to the DAO to receive a data request. It will contain the necessary functions for analyzing the request and setting properties. Basically, it will combine most of the โ€œserviceโ€ layer with a bean, leaving a direct database in the DAO layer.

Of course, for the controller / views, both beans will look and act the same.

But the question is memory and how ColdFusion / Java deals with it.

Using an anemic model, the bean will have enough memory to store variable properties with just one touch to point to the Service when needed.

With heavier features of the second type of bean, will the cache require more memory? Will each bean copy have a full copy of the methods?

I am inclined to think that the second model will not have much more memory, since they "divide" the methods and only need memory for variable properties.

IMHO the second method would simplify the code base, since the bean code would be closer to the bean, and not scattered between the DAO and the services. And this would reduce the simple functions in the Service, which would simply pass DAO calls from the bean, could go directly to the DAO, when it was necessary ...

Does the question make sense? Or at least how do I ask this?

+6
source share
2 answers

All memory management is passed at the Java level, so it follows the same rules. In Java, the only "new" memory that is allocated when creating an instance of an object is for its member variables; for the methods of the component / class itself, a memory note is not printed: this material is stored only once in memory, referring to it.

One possible consideration is that each CFC method compiles as its own discrete class (why? I don't know), so each method is its own class. This may mean a little more memory for using CFC compared to using the Java class, but it still will not be what is scaled by creating an object: each instance of the object will still just consume memory for its member variables, and not the CFC methods that the object defines.

+3
source

all cfm pages are compiled into memory by default, CFC must be implicitly stored in memory (for example, the application area) to avoid its instance every time, however, this requires the same memory for the same component, any additional use will depend from any data that you store in your component or bean. Have you seen ColdSpring?

0
source

All Articles