Ruby-mri is consuming lots of memory

Hiii Frnds,

I am newbie to Ruby. When i run my app using Rails server it consuming lots of memory. I am running my app Thin web server. When i run my app system hanged out every time. When gogled it , I found its a known issue of Ruby. How can i solve this??? Plzzzz help.

Your post isn’t really informative enough for us to give you an answer. Have you tried profiling your code and checking web requests for slow times?

The following article should help you to do this: 4 Simple Steps to Detect and Fix Slow Rails Requests. If you can provide us with what’s causing the problem, then we may be able to suggest a solution.

Thanks tpunt for quick response. Actually i am trying to run a website. It is developed in ruby on rails. I am using Fedora 20 and run that app on Thin server. When i run this app Ruby-mri is consuming memory in MBs, as i have checked in System Monitor. After run the first page memory usages is 1.6 GB and i have 2 GB RAM. I have searched on google n found it is because some GC Parameters named RUBY_HEAP_MIN_SLOTS,RUBY_FREE_MIN,RUBY_GC_MALLOC_LIMIT. How can i edit these parameter’s value or where to find these???

Whatever you said m trying. If anything new kindly share.

I actually partially know this. :smile:
You can create a file named .env and place them each on a line (place the value following the =):

RUBY_HEAP_MIN_SLOTS=
RUBY_FREE_MIN=
RUBY_GC_MALLOC_LIMIT=

Then when you start your application again, it should take those into consideration.

Hii capradio ,but I am not using Ruby Enterprise edition. Does it effects on what u repiled. Where to create this file and of what name??

Good question. So the .env only applies to the running user (as you’d put it in their home directory). If you want it to be system wide, you want to edit the /etc/environment file (as described at).
http://www.rubyenterpriseedition.com/documentation.html#_configuring_ree_as_the_default_ruby_interpreter

What Ruby version are you running?

I am using ruby 2.0.0p353 (2013-11-22 revision 43784) [x86_64-linux].

Is it must to use Ruby Enterprise Edition ???

I have checked my /etc/environment file but it is empty. I am using Fedora 20.

OK. There were some performance issues with Ruby 1.9 and Rails. Just wanted to check that that wasn’t the case.

If your rss is higher than say 300mb it is a strong signifier you have issues with your application code

Post is really thin on details, you need to include tons more, also have a look a rack mini profiler and memory profiler gem

I have solved that issue. Different ruby versions create problem. Now i am facing another issue. Iam using PostgreSQL database, done all database entries through console. I am getting stuck on one statement “@user = login(params[:email],params[:password])” here @user has null value so that m getting Login failed message. I dont understand why @user have no values as database is connected with my application???