0

i have an application which is using this a lot

<cfset SetVariable("b.vari.#c.i#",variables[c.i])>

how can simply it in better way using cf2021 now.

i tried following the urls from a website but i am not sure, they are using some [ operator which i can't get around

i tried like this

<cfset b.vari['c.i'] = variables[ci.i]>

is that above right, i am not sure about and i think the code i have written below foes not make sense, please guide if i am doing anything wrong here

Roza
  • 19
  • 4

1 Answers1

4

I don't think the code you're talking about could cause a Java heap space issue unless you have low memory allocation settings for the server's JVM config and an extremely high volume of requests. Are you running a single instance of the server? Multiple instances behind a load balancer?

So this code

<cfset SetVariable("b.vari.#c.i#",variables[c.i])>

is the same as

<cfset b.vari[c.i] = variables[c.i]>

is technically

<cfset variables.b.vari[c.i] = variables[c.i]>

So you're double-stacking the same data into the variables scope of the request. Dump the variables scope after that line and you'll see the same data in there twice.

<cfdump var="#variables#">

BUT, a struct and other complex objects in CF are passed by reference and not by value. So both variables should be referencing the same memory space that was taken by variables[c.i].

You might check the -Xms (initial memory allocation) and -Xmx (maximum memory allocation) settings of your CF server's jvm.confg file. You can either edit this in the JVM settings section of CF admin directly in the file of that name.

If you've never edited those values from the defaults, you might have too little memory allocated for your CF server compared to what's available to the server as a whole. It's often the case that your application's usage eventually crosses a threshold that requires you to add and allocate more RAM to the server to handle the increased load.

While you're in there, check if the server is referencing the version of Java that shipped with your CF installation. You might also be behind on the recommended current secure version of Java for your version of CF.

What are the -Xms and -Xmx parameters when starting JVM?

https://www.cfguide.io/coldfusion-administrator/server-settings-java-jvm/

Adrian J. Moreno
  • 14,350
  • 1
  • 37
  • 44
  • this is the screenshot of the memory section, i used some code from google to figure out what is happening https://prnt.sc/0ZvOdiyoh5Y9 – Roza Dec 23 '22 at 12:51
  • and my jvm minium heap size is 512 and maximum is 2048 – Roza Dec 23 '22 at 13:07
  • That's really low for a production site. How many users do you get daily and how many concurrent users at peak times? If you've got more available RAM, you might make the minimum `2048` and triple the maximum. Your app has likely grown past the current settings and you need room for it to breathe. – Adrian J. Moreno Dec 28 '22 at 15:40