Hi Dino,
Any chance you are running your development environment instead of
production environment?
If you're running your dev env, and it's config'd like a typical
default dev env, each request to the app will re-load the entire
stack, and that stack will be cached. This is so that any changes you
make to the app are immediately reflected in the app on the next
request made on the app, which is what you'd want when your dev'ing
your app. However, the longer you run under dev env, the more memory
that dev env process will consume. This is not the case with a
typical production env setup, in which app code mods would require an
app restart to pick up such mods.
Regardless, if you want to log your app instance(s)'s resource usage
upon each request for analysis purposes (and you're running under
linux/unix) you could do something like:
# in app/controller/application.rb:
...
before_filter :log_resource_usage
...
private
def log_resource_usage
# see ps man page: http://unixhelp.ed.ac.uk/CGI/man-cgi?ps
x,psr,etime,pcpu,pmem,rss,vsz = `ps -o psr,etime,pcpu,pmem,rss,vsz
-p #{Process.pid}`.split('\n')[1].split(/\s+/)
logger.info("***INFO: resource_usage: rails_env=#{RAILS_ENV} pid=#
{Process.pid} psr=#{psr} etime=#{etime} pcpu=#{pcpu} pmem=#{pmem} rss=#
{rss} vsz=#{vsz} req_method=#{request.method} req_uri=#{request.env
['REQUEST_URI']}")
end
...
which will produce log entries like:
***INFO: resource_usage: rails_env=development pid=22401 psr=0
etime=14:38:23 pcpu=0.0 pmem=3.1 rss=32620 vsz=59952 req_method=get
req_uri=/testapp/some/such/request
Jeff
On Feb 15, 6:41 am, "dino d." <[email protected]> wrote:
> Hi-
>
> My app has reached the memory limit allotted by my host. Can someone
> tell me how I go about reducing the memory footprint? Does rails load
> every single gem it finds, and can I somehow throw away the ones I
> don't need? Any other advice or suggestions for strategies or tools
> to diagnose where memory is being used would be appreciated.
>
> Thanks,
> Dino
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---