Shamlessly stolen from adobe.com
Solaris and Linux [adobe.com]
The "VSZ" (Virtual Memory Size) column is the most applicable for memory usage evaluation and equates with Windows "VM Size." The "RSS" column simply how much virtual memory is currently in physical RAM. Both "VSZ" and "RSS" can be obtained with the ps command.
Solaris
Code:
#!/bin/sh
#
# cfmemstat - monitor cfserver memory utilization
#
pid=`cat /opt/coldfusion/log/pids/server.pid`
# pid=`cat pidfile`
arg=$1
outfile=cfmemstat.log
printf "CFMEMSTAT started at: " >> $outfile
echo ${tmp-`date`} >> $outfile
while true
do
ps -o pid,vsz,rss,pmem,time,comm -p $pid >> $outfile 2>&1;
sleep $arg;
done
exit
Linux
Code:
#!/bin/sh
#
# cfmemstat - monitor cfserver memory utilization
#
pid=`cat /opt/coldfusion/log/pids/server.pid`
# pid=`cat pidfile`
arg=$1
outfile=cfmemstat.log
printf "CFMEMSTAT started at: " >> $outfile
echo ${tmp-`date`} >> $outfile
ps -o pid,vsz,rss,pmem,time,comm -p $pid >> $outfile 2>&1;
while true
do
ps -h -o pid,vsz,rss,pmem,time,comm -p $pid >> $outfile 2>&1;
sleep $arg;
done
exit
To use, copy and paste these lines into an editor window, save the file as "cfmemstat," change the file permission, and execute:
Code:
# chmod 755 cfmemstat
# ./cfmemstat [mem sample interval in seconds]
The # ./cfmemstat 600 will log to a file "cfmemstat.log" in the same directory every 10 minutes and spawn the process in the background.
All of these commands assume that ColdFusion was installed in /opt/coldfusion.
When using these utilities, remember that the "size" parameter differs from Linux to Solaris. Therefore, "VSZ" statistic is what you want to monitor. On Solaris, top "size" may equal ps "VSZ," but on Linux, it appears to be the "RSS."
Things to Check in ColdFusion Applications
The release and reacquisition of the memory cycle places a significant drain on server resources. That was the main reason for the change from CFAS4.0 to CFAS4.5. If your application needs a certain amount of memory at one point in time, it will never need less. This makes it appear that memory usage is always rising and giving the impression of a leak.
Depending on the application and the complexity of the Web site, a well-behaved site's memory usage will grow but eventually plateau. On a number of very complex sites, Allaire closely examined reports of memory usage growing without bound. In many of the cases, the problems were traced to a documented leaky DB driver or gargantuan amount of cached queries.
In the case of the cached query problem, this was due to a slight difference in each query. In another case, the memory plateau was higher than expected. Once enough swap space was configured the memory plateau was established. No ColdFusion application independent memory leak was identified in any of the cases reported.
Here is a checklist for possible causes for increased memory usage:
- Check which MDAC version is being used. In many of the reported cases, the MDAC version 2.1.3711.11 contained a documented memory leak.
- Examine ColdFusion query caching to make sure no differences appear.
- Make sure that growing files, logs, or record sets are not being brought into memory, even if only for the duration of the request.
- Check accumulating states in persistent scopes, including server, application, and session.
- Operations on collections (e.g., CFSearch and CFIndex) can cause growth over time.
- Keep in mind that operations needing large contiguous blocks of memory like CFFile or CFHTTP can take longer to plateau.
- Homegrown CFX tags may be allocating memory and not properly freeing it up.
- When running tests for memory usage, check for the existence of any application.cfm files located in the directory path that enable session, application, or server variables. These variables may add processing cycles or additional demand on memory, which may not be immediately apparent.
- One of the most common causes are improperly locked access to session, application, and server variables. These variables are stored in memory and need to be enclosed in a CFLOCK tag with the appropriate SCOPE attribute specified (i.e. session, application, or server) when referenced.
- When accessing client variables stored in an Oracle DB with the CFAS native driver for Oracle, see KB article 15885.
* I hope that helps some.