Mac OSX Lion 和 Ruby - [致命] 无法分配内存 [英] Mac OSX Lion and Ruby - [FATAL] failed to allocate memory

查看:50
本文介绍了Mac OSX Lion 和 Ruby - [致命] 无法分配内存的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在使用 Ruby 和 OSX Lion 时遇到严重问题 - 每当我尝试启动 Rails 或什至是 rake 工具时,我都会收到此错误:

I have serious problem with Ruby and OSX Lion - whenever I try to start Rails or even a rake tool I am getting this error:

[FATAL] failed to allocate memory

我尝试在不同版本(1.9.2-p180、1.9.2-p290、1.9.2-head)中重新编译 ruby​​,结果总是一样.

I tried recompilling ruby in different versions (1.9.2-p180, 1.9.2-p290, 1.9.2-head) and its always the same.

但是我注意到我可以移除一些宝石,然后耙子"工具将起作用,只有rails"会因该错误而死亡.对于我正在使用的这么多宝石,实际上似乎没有足够的内存,但这又看起来很奇怪——它在 Snow Leopard 上运行得非常好,甚至在我公司的 mac mini 和 Lion 上都运行良好——唯一的区别是mini 升级了 Snow Leopard -> Lion,而在我的 iMac 上,它是一个干净的 Lion 安装.

However I noticed that I can remove some gems and then "rake" tool will work and only 'rails s' will die with that error. It seems like there is in fact not enough memory for this amount of gems I am using, but again this seems very weird - it works perfectly fine on Snow Leopard and even at my company on mac mini with Lion - the only difference is that the mini is upgraded Snow Leopard -> Lion, whilst on my iMac its a clean Lion installation.

有什么想法吗?是否有某种设置可以增加 OSX/Lion 上的内存?

Any ideas? Is there a setting of some kind to increase memory on OSX/Lion?

推荐答案

我花了一些时间才弄明白,但这里是解决方案:

It took me some time to figure it out but here is the solution:

这个问题是由mysql2 gem引起的,当我切换到ruby-mysql时,它又开始工作了(记得从mysql2更改适配器> 到您的 database.yml 中的 mysql!)

This problem was caused by mysql2 gem, when I switched to ruby-mysql it all started working again (remember to change adapter from mysql2 to mysql in your database.yml!)

所以我开始思考 mac mini 和 iMac 之间的区别.基本上,mini 运行的是从 Snow Leopard 升级的 Lion,后者是升级的 Leopard,它具有用于 mysql 和 pgsql 服务器的良好的旧 Mac 端口.所以当 gem 被编译时使用端口库.

So I started thinking about differences between mac mini and iMac. Basically the mini is running Lion upgraded from Snow Leopard, which is upgraded Leopard and it has good, old Mac Ports for mysql and pgsql servers. So when gem is compiled its using port libraries.

另一方面,安装了全新 Lion 的 iMac 具有 Zend Server 包(apache + php + mysql 二进制文件)和 Homebrew 包mysql-connector-c",其中包含编译 gem 所需的库.

On the other hand the iMac with fresh Lion installation has Zend Server package (apache + php + mysql binaries) and a Homebrew package 'mysql-connector-c' that has libraries needed to compile gem.

总而言之,似乎 mysql 的端口版本工作正常,而 Homewbrew 连接器却没有(它泄漏了一些内存?).

All in all it seems as if ports version of mysql works correctly whereas Homewbrew connector does not (its leaking some memory?).

希望这会有所帮助.

这篇关于Mac OSX Lion 和 Ruby - [致命] 无法分配内存的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆