Welcome to the Linux Foundation Forum!

apache make httpd cannot allocate memory

I was doing the build step for apache http server, and I kept getting this error saying something could not allocate memory. I did some searching, and I didn't exactly find an answer, but it seems that the problem may have been that my server just didn't have enough memory to execute the make in one go. So I kept on trying, and that seems to have worked (still working on the apache installation).

My question is: do you think the lack of memory was really the problem here? I just setup this virtual dedicated linux server with godaddy. It's the smallest version, economy, but it says it has 1GB of RAM, so I'm surprised.

Comments

  • mfillpot
    mfillpot Posts: 2,177
    I do not believe this has to do with the amount of RAM, maybe it could be a lack of hard drive space. Without the exact error message we cannot figure out what the true cause was.
  • woboyle
    woboyle Posts: 501
    It may have run out of memory. With 1GB of RAM for your virtual machine, how much swap space has been allocated?
  • marc
    marc Posts: 647
    Looks like you run out of ram.

    Compiling software takes much more ram than just using it ;) (usually at least)

    Regards
  • tomasr
    tomasr Posts: 19
    @mfilpot, yeah, I should have written it down. I believe it was an malloc out of memory exception. It didn't really say much else than that. I'm guessing that I have somewhat less than 20GB of free space; that's how much comes with the plan, and I haven't installed anything except for apache.

    @Rubberman, not sure how much swap space is allocated. I'll check tonight.

    @marc, is that so? It could see compiles requiring a lot of memory to hold all the definitions and trees.

    FYI, the installation was successful - happy!
  • tomasr
    tomasr Posts: 19
    edited January 2012
    FYI, my swap space appears to be 0 bytes. As I understand it, swap space sort of extends the actual amount of RAM that can be used, and so here I have 0. This implies that my system was attempting to allocate more than 1GB of RAM.

    Is there a log file I can check to see how much RAM the system was attempting to allocate at the time that I was running this build?

    Here is the /proc/meminfo snapshot.

    MemTotal: 1048576 kB
    MemFree: 976056 kB
    Buffers: 0 kB
    Cached: 0 kB
    SwapCached: 0 kB
    Active: 0 kB
    Inactive: 0 kB
    HighTotal: 0 kB
    HighFree: 0 kB
    LowTotal: 1048576 kB
    LowFree: 976056 kB
    SwapTotal: 0 kB
    SwapFree: 0 kB
    Dirty: 0 kB
    Writeback: 0 kB
    AnonPages: 0 kB
    Mapped: 0 kB
    Slab: 0 kB
    PageTables: 0 kB
    NFS_Unstable: 0 kB
    Bounce: 0 kB
    CommitLimit: 0 kB
    Committed_AS: 0 kB
    VmallocTotal: 0 kB
    VmallocUsed: 0 kB
    VmallocChunk: 0 kB
    HugePages_Total: 0
    HugePages_Free: 0
    HugePages_Rsvd: 0
    Hugepagesize: 2048 kB
  • woboyle
    woboyle Posts: 501
    Rule of thumb: allocate 2x swap to available RAM, at a minimum. So, since you have 1GB RAM, create a swap space or swap file (use the swapon command to do this) of 2GB, at a minimum. You can increase this later if you need.
  • tomasr
    tomasr Posts: 19
    Thanks, Rubberman. I have learned that I cannot create swap space because I'm using a godaddy virtual dedicated server. http://support.godaddy.com/groups/web-hosting/forum/topic/am-i-allowed-to-setup-swap-disk-on-vps/
  • marc
    marc Posts: 647
    You could recompile linux-utils and then you'd be able to create swap spaces on disc :)

    Regards
  • woboyle
    woboyle Posts: 501
    Well, even if you cannot create a swap partition, you should be able to create a swap file. As reader marc suggested, install/compile the linux-utils package if you need and do not have access to the swapon command in your VM. All you should need is disc space (real or virtual).
  • mfillpot
    mfillpot Posts: 2,177
    If you would like to make a swap parse file you can follow these steps, in this case the swap file is being stored as /root/swapme. (Run all of these commands as root)
    # Make a 1GB empty File
    dd if=/dev/zero of=/root/swapme bs=1M count=1024
    
    # format the file as swap
    mkswap /root/swapme 
    
    #To mount it immediately, you can use
    swapon /root/swapme 
    
    #To make sure it is always mounted on boot you need to add the following line to /etc/fstab
    /root/swapme     swap             swap        deafaults        0   0
    

    Call it whatever you want, swapme was a fast name that I used to test the steps.
  • tomasr
    tomasr Posts: 19
    edited January 2012
    It appears linux-utils is the same as util-linux, correct?

    @mfillpot - thanks, swapon is what I tried at first and it failed. I searched about the error and hit that godaddy support thread that I posted. I still tried changing fstab and rebooting, but doesn't appear to have done anything.
  • mfillpot
    mfillpot Posts: 2,177
    I would assume that the linux-utils and utils-linux are the same, can you pleas tell us what distro you are using so we can confirm the contents?

    As for the swapon command, can you please paste the error message or tell us what it does when that command fails?

    can you please tell me the steps and errors messages that resulted when you followed by script? I am curious about the naming conventions you use and to verify that your instructions are all pointing to the same source.
  • marc
    marc Posts: 647
    Godaddy probable remove the suport for that in it's binaries. That's why I suggested to recompile linux-utils (or util-linux)

    Regards
  • tomasr
    tomasr Posts: 19
    Hello! I got distracted from this for a while, but I'm getting back to it.

    I'm looking up the util-linux package to learn what to do,but I have a question that I hope would save me some unnecessarily lost time.

    On my server, I have util-linux-ng.i686 rpm package installed (it shows up in yum list installed; it came that way on the machine). So I think I ought to uninstall that package (yum remove), then compile and install the new util-linux (from https://github.com/karelzak/util-linux?) - correct?
  • woboyle
    woboyle Posts: 501
    See http://en.wikipedia.org/wiki/Util-linux

    The util-linux-ng package is a standard package, installed by default on RHEL 6.x and clones. Your server indicates that. Don't bother, unless there is something that you really need from the one you are proposing to install.
  • tomasr
    tomasr Posts: 19
    Eh...so I learned how to compile util-linux. Then I figured I'd remove the one from the package manager, and then drop-in my new one. But when I ran yum, it removed everything! Well, it removed a lot of stuff, destroying my ability to sudo or remote terminal.

    At the moment, I'm working on getting my machine back to normal, but in the mean time, is there an option or prompt for yum remove that I missed? Also, I suspect many programs may be expecting a certain version of the util-linux files, and therefore fail, but this I'm really uncertain of.
  • woboyle
    woboyle Posts: 501
    That package has a lot of stuff that other components of the operating system required for most normal use, so it is listed as a dependency in those other packages. As a result, when you removed util-linux, you removed all the dependent stuff as well, resulting in ... well, now you know. This is why yum, as a default, will list what it is going to install or remove and then ask if you want to continue the operation.

    Unfortunately there is no quick fix for this except to reinstall the OS. You can install all the removed packages manually, but that will take a LOT longer than a simple reinstall/repair. Some installers will let you repair the installation, re-installing the default package set without munging current configurations of other stuff in /etc for example. In any case, you will have a lot of work to do to get back to where you were.

    My recommendation in such cases is not to uninstall the package in question, but to install it in /usr (the default --prefix option for source packages is /usr/local, normally). If that causes problems, then you can fix that with a simple "yum reinstall util-linux" command. That will restore the default system version of those applications and such.

Categories

Upcoming Training