Unix Technical Forum

Building MySQL Under low memory conditions (CFLAGS not working?)

This is a discussion on Building MySQL Under low memory conditions (CFLAGS not working?) within the MySQL General forum forums, part of the MySQL category; --> Hi, I'm trying to build MySQL 4.1.22 on a VPS where it looks like our available memory could be ...


Go Back   Unix Technical Forum > Database Server Software > MySQL > MySQL General forum

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-28-2008, 06:15 AM
Weston C
 
Posts: n/a
Default Building MySQL Under low memory conditions (CFLAGS not working?)

Hi,

I'm trying to build MySQL 4.1.22 on a VPS where it looks like our
available memory could be as low as 32MB, and compilation is erroring
out partway through with a "virtual memory exhausted: cannot allocate
memory" message.

I tried invoking configure with the "--with-low-memory" flag, and then
recompiling, and was still bumping up against the same issue.

So I went looking for any other info I could find out on the net, and
did find some specific info about flags you can feed to gcc to keep
memory usage low here:

http://hostingfu.com/article/compili...low-memory-vps

However, near as I can tell, when I add the flags --param
ggc-min-expand=0 and --param ggc-min-heapsize=8192 to CFLAGS in the
Makefile in the top-level source directory, nothing changes. The
output of make seems to indicate it's using the same flags as before I
changed the makefile. In fact, it looks like I can remove CFLAGS
entirely or change it to something like CFLAGS =
--hovercraft-full-of-eels and nothing changes.

Any obvious things I'm missing? Ideas for other things I could try?

Thanks,

Weston
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 02-28-2008, 06:17 AM
Joerg Bruehe
 
Posts: n/a
Default Re: Building MySQL Under low memory conditions (CFLAGS not working?)

Hi Weston, all,

Weston C wrote:
> Hi,
>
> I'm trying to build MySQL 4.1.22 on a VPS where it looks like our
> available memory could be as low as 32MB, and compilation is erroring
> out partway through with a "virtual memory exhausted: cannot allocate
> memory" message.


32 MB isn't much, nowadays - consider the complexity of C++ and the
amount of header files needed during compilation.

Also, "virtual memory" is not just RAM, it also includes your paging
space (aka "swap device"): check its size and usage.

>
> [[...]]
>
> However, near as I can tell, when I add the flags --param
> ggc-min-expand=0 and --param ggc-min-heapsize=8192 to CFLAGS in the
> Makefile in the top-level source directory, nothing changes. The
> output of make seems to indicate it's using the same flags as before I
> changed the makefile. In fact, it looks like I can remove CFLAGS
> entirely or change it to something like CFLAGS =
> --hovercraft-full-of-eels and nothing changes.
>
> Any obvious things I'm missing? Ideas for other things I could try?


AFAIK, the CFLAGS value in a Makefile is not automatically passed to
"make" runs in subdirectories. Better try this:

cd <top-level-dir>
configure <your-options-here>
CFLAGS="--param ggc-min-expand=0 --param ggc-min-heapsize=8192" make

This way, you have the setting in the environment, and that is inherited
(unless modified).

HTH,
Joerg

--
Joerg Bruehe, Senior Production Engineer
MySQL AB, www.mysql.com
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 02-28-2008, 06:17 AM
Weston C
 
Posts: n/a
Default Re: Building MySQL Under low memory conditions (CFLAGS not working?)

Joerg Bruehe <joerg@mysql.com> wrote:
> Also, "virtual memory" is not just RAM, it also includes your paging
> space (aka "swap device"): check its size and usage.


This is a really good point. Are there some other parameters (either
compiler or environment) I should be trying to tweak in addition to
ggc-min-expand and ggc-min-heapsize?

> AFAIK, the CFLAGS value in a Makefile is not automatically passed to
> "make" runs in subdirectories.


That's exactly it. I just verified it by changing the CFLAGS and other
variables in a sub-directory Makefile, and sure enough, they work
there. Interesting!

> Better try this:
>
> cd <top-level-dir>
> configure <your-options-here>
> CFLAGS="--param ggc-min-expand=0 --param ggc-min-heapsize=8192" make


This totally works -- thank you! At least, it gets me further in the
compilation process. It seems even with those flags, I'm still getting
the "virtual memory exhausted" error.... just much later instead of
almost right off the bat. So I guess I'm back to wondering if there
might not be other parameters I should try tweaking.

Thanks,

Weston
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 02-28-2008, 06:17 AM
Joerg Bruehe
 
Posts: n/a
Default Re: Building MySQL Under low memory conditions (CFLAGS not working?)

Hi Weston, all!

Weston C wrote:
> Joerg Bruehe <joerg@mysql.com> wrote:
>> Also, "virtual memory" is not just RAM, it also includes your paging
>> space (aka "swap device"): check its size and usage.

>
> This is a really good point. Are there some other parameters (either
> compiler or environment) I should be trying to tweak in addition to
> ggc-min-expand and ggc-min-heapsize?


If your RAM is limited, you will profit from running as few programs as
possible, and configuring these to use as little address space as possible.

Specifically about gcc, I cannot give any hint. Our build environments,
be it central servers or local workstations, have much more RAM.

>
>> AFAIK, the CFLAGS value in a Makefile is not automatically passed to
>> "make" runs in subdirectories.

>
> That's exactly it. I just verified it by changing the CFLAGS and other
> variables in a sub-directory Makefile, and sure enough, they work
> there. Interesting!


That's like the difference between a local and an exported shell variable.

>
>> Better try this:
>>
>> cd <top-level-dir>
>> configure <your-options-here>
>> CFLAGS="--param ggc-min-expand=0 --param ggc-min-heapsize=8192" make

>
> This totally works -- thank you! At least, it gets me further in the


Good to hear !

> compilation process. It seems even with those flags, I'm still getting
> the "virtual memory exhausted" error.... just much later instead of
> almost right off the bat. So I guess I'm back to wondering if there
> might not be other parameters I should try tweaking.


The only other thing that comes to my mind is to avoid parallel make
runs - best use "make -j 1" explicitly.

I repeat:
Check your swap space size and its use. If that server is a Linux
machine, try
cat /proc/swaps

On my home PC, the current output is
Filename Type Size Used Priority
/dev/hda6 partition 987988 28056 42

(964 MB configured, 27 MB used -
this is with two builds running in parallel on 1 GB of RAM, plus the
interactive use with KDE, Firefox, Thunderbird, IRC, ...).

Also, use "ps" to check for the address space used by running processes.


Good luck !

Joerg

--
Joerg Bruehe, Senior Production Engineer
MySQL AB, www.mysql.com
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 12:55 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com