as there is no obvious leak happening, we have to assume that the
[opensuse:software-o-o.git] / app / controllers / application_controller.rb
1 # Filters added to this controller apply to all controllers in the application.
2 # Likewise, all the methods added will be available for all controllers.
3
4 class ApplicationController < ActionController::Base
5
6   after_filter :check_memory
7
8   init_gettext('software')
9
10   def rescue_action_in_public(exception)
11     @message = exception.message
12     if request.xhr?
13       render :template => "error", :layout => false, :status => 404
14     else
15       render :template => 'error', :layout => "application", :status => 404
16     end
17   end
18
19  private
20   def check_memory
21     mu = get_memory
22     if mu > 80000
23       logger.error 'Memory limit reached, ending process'
24       `kill -1 #{$$}`
25     end
26   end
27   
28   def get_memory
29     `ps -o rss= -p #{$$}`.to_i
30   end
31
32 end