如何知道特定 ColdFusion 变量或 ColdFusion 作用域的每个属性正在使用多少内存?
我目前正在 ColdFusion 中缓存查询。它有几千条记录和大约 30 列 - 其中大多数是 VARCHAR 列。我很好奇这使用了多少内存,以确定是否真的值得将其存储在缓存中。我怎样才能真正找到缓存查询和/或任何变量正在使用的内存量(例如应用程序范围)?
I'm currently caching a query in ColdFusion. It has a few thousand records and about 30 columns - most of them are VARCHAR columns. I'm curious how much memory this is using, to determine if it's really worth storing it in the cache. How can I find out the amount of memory that is being used by a cached query and/or any variable, really (APPLICATION scope for example)?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
如果您使用的是 CF Enterprise(或 Developer),则可以从 CF 管理员打开服务器监视器,然后 查看内存使用情况。但不要在生产系统中执行此操作,因为内存跟踪器可能会严重导致 CF 服务器陷入困境。
If you're using CF Enterprise (or Developer), you can open the Server Monitor from the CF Administrator and view the memory usage. Don't do this in a production system though, as the memory tracker can seriously bog down a CF server.
在 Railo 中有一个
SizeOf(obj)
函数,它可以告诉你有多少内存被一个对象使用。根据设置的容易程度,您可以考虑在 Railo 上运行应用程序,缓存查询,然后调用
SizeOf
来获取您想要的信息。它可能不会完全相同(取决于内部存储方式的具体情况),但应该给出一个粗略的想法。
(ps 只是建议使用 Railo 进行此测量 - 并不建议您完全切换;当然除非您愿意。)
In Railo there is a
SizeOf(obj)
function, which can tell you how much memory is being used by an object.Depending on how easy it would be to setup, you could consider running your app on Railo, caching the query, then calling
SizeOf
to get the information you want.It's probably not going to be exactly the same (depends on specifics of how things are stored internally), but should give a rough idea.
(p.s. Just suggesting to use Railo for this measurement - not suggesting you switch over entirely; unless of course you want to.)
不幸的是,没有 CF/Java sizeOf() 人们可能期望找到做这类事情的方法,而这正是人们最初期望能够做的事情。谷歌“java sizeof”以获取比您可能想阅读的有关该主题的更多信息。
正如 Dan 所说,服务器监视器可以做到这一点。如果您想以编程方式查看此类事情,它还有一个 API: http://localhost: 8500/CFIDE/adminapi/servermonitoring.cfc。
文档在这里:
http://help.adobe.com/en_US/ColdFusion/9.0/Admin/WSc3ff6d0ea77859461172e0811cbf363cdd-7ff4.html
示例代码:
您需要打开服务器监控才能返回任何内容(雷·卡姆登 (Ray Camden) 为我提供了这方面的帮助;-)
Unfortunately there is no CF/Java sizeOf() which one might expect to find to do this sort of thing, which is what one might initially expect to be able to do. Google "java sizeof" for more information than you're likely to want to read on the subject.
As Dan said, there's the server monitor, which will do it. It also has an API if you want to look at this sort of thing progammatically: http://localhost:8500/CFIDE/adminapi/servermonitoring.cfc.
Docs are here:
http://help.adobe.com/en_US/ColdFusion/9.0/Admin/WSc3ff6d0ea77859461172e0811cbf363cdd-7ff4.html
Sample code:
You need to have server monitoring switched on for this to return anything (cheers to Ray Camden for helping me with that bit ;-)