> I have a bunch of xml files from which my application creates cached
> queries for use in the application. While all the xml files put
> together are not more than a megabyte, memory usage on my CFMX 6.1
> Server (Running on Windows 2003 and IIS 6.0; 1GB RAM) spikes up to
> about 400 MB when the app. is running.
> My question then is- Is there a way to find out exactly how much each
> cached query and other objects (I have components being loaded) are
> using up in the memory?
Hi Nikhil,
There is no easy way to determine the size of an object in java, there
is no sizeof function for instance. To determine the size of an object
you need to add up the size of all the primitive data members within the
object. In CF there are no primitives, most simple objects are stored as
strings which are double byte (2 bytes for each character). So to find
the approximate site of a query you might do something like this:
<cffunction name="sizeOfQuery" returntype="numeric">
<cfargument name="query" type="query" required="true">
<cfset chars = 0>
<cfoutput query="arguments.query">
<cfloop list="#arguments.query.columnlist#" index="column">
<cfset chars = chars +
Len(Evaluate("arguments.query.#column#"))>
</cfloop>
</cfoutput>
<!--- multiply by two since chars in java are double bytes --->
<cfreturn chars * 2>
</cffunction>
then call it:
<cfoutput>#sizeOfQuery(somequery)#</cfoutput> bytes.
For components you would need to add up the size of all the data within
the component - loop through each array, structure, or query - find the
total length and multiply by 2.
In actuality the objects may be taking up a bit more room than the size
of its data. The objects that hold the data may also have their own meta
data (such as an integer storing the size).
Also keep in mind that your CF Server is storing more than just your
variables in memory, it is also caching compiled CFM files, database
connections, etc.
___________________________________
Pete Freitag
http://www.cfdev.com/
Author of the CFMX Developers Cookbook
http://www.petefreitag.com/bookshelf/
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]

