I’m experimenting with the Application.cfc within coldfusion. I’d like to know if the application.cfc is static in memory, i.e it’s created once for the first user and there after every user that accesses it accesses the same application.cfc (within memory).
Example.
UserOne accesses webpage > Application.cfc is created at memory block 1.
UserTwo accesses webpage > Application.cfc at memory block 1 is called again but function onRequestStart is called.
Am I correct in saying that the application.cfc is static within the memory (or until it expires) or is it recreated for every single user? Would this be a huge memory issue if it was?
Can someone explain thanks.
Application.cfc is executed for every request but only parts of it are run depending on the situation. The pseudo-constructor (where you set this.name type settings) is executed each time and cannot be changed problematically. onApplicationStart() only runs if the application doesn’t exist. The application scoped variables are accessible to every session and only exist once per application instance (not session instance). onSessionStart() only runs the first time a new visitor hits the site. There are other event specific functions
Here is another thread that may may help with your question.
As well as adobe docs:
An active user counter is as easy as something like pseudo code:
Clearing up some confusion
The ‘this’ scope is used to set application settings such as the name, sessionTimeOut, or customTagPaths. These settings are built into ColdFusion.
Although the ‘this’ scope is related to the application, you cannot use it to set persistent application scope variables. Application variables are set by using the ‘application.’ syntax and is usually initially set in the onApplicationStart() function.