Carmem
Carmem

Reputation: 1

Application.cfc variables and memory in scope application

I had a problem with an application in coldfusion 9 and application.cfc. In the onRequestStart method there were variables with application scope example:

<cffunction name = "onRequestStart">
    <cfset application.URL_Images = 
    '<img src = "http: // # server_name #: # server_port # / aseng / images / logo1.jpg">'>
</cffunction>

As I have many people accessing the application, the server gave a timeout and I saw in the Monitor that the scope application was consuming a lot of memory.

The question is, do application scope variables in Application.cfc consume more memory than in Application.cfm?

In Application.cfm the server didn't happen to crash.

I have variables that need to be validated for each request because they receive different values ​​depending on the type of access. We have remote access and local access which are separate ports.

How can I set these variables without consuming memory on the server? To work around the problem, I went back to Application.cfm until I was sure that Application.cfc was created correctly.

Thanks

Upvotes: 0

Views: 203

Answers (1)

Adrian J. Moreno
Adrian J. Moreno

Reputation: 14859

Do application scope variables in Application.cfc consume more memory than in Application.cfm

Answer: No. Not at all.

You may be setting things into the application scope that shouldn't be. That code says that for all users, for each request, redefine an application level variable. Seems like that value should be a request level variable as it changes based on the user and their settings.

  • User 1 starts a request and sets the value of application.URL_Images.
  • User 2 starts a request and sets the value of application.URL_Images.
  • User 1 completes their request and reads the value of application.URL_Images, which has now been changed.
  • User 2 completes their request and everything's ok.
  • User 1 wonders why they are seeing the wring logo.

It may just be the case that your application load is reaching current resource limits. Odd that it's only acting oddly with the cfc and not the cfm.

  • Check on your JDK version and make sure it's the latest supported by CF 9
  • Verify that you have enough memory allocated to your application instances.

Finally, review how you structured your Applicaiton.cfc. There may be something else in there overloading the application scope based on the CFC function triggers that is running under a different condition in the CFM. I would explore more of what else is in the application scope and ensure what is there, when it is loaded and if it needs to be "cached" there.

Upvotes: 1

Related Questions