virtual memory exhausted: Cannot allocate memory

user1382306 picture user1382306 · Mar 4, 2013 · Viewed 14.8k times · Source

My compilation fails on ubuntu 12.10 with 300mb memory available (750mb total, 350mb to MySQL), 1.5ghz, I am trying to rework wt's basic hello world file into a simple ajax page. I'm pretty sure it's not a memory issue at heart since I was able to compile the original hello.C file with g++ -O3 -o hello hello.C -lwtfcgi -lwt -lboost_signals.

I'm sure I'm screwing up the c++ since I ripped out the guts of HelloApplication::HelloApplication(const WEnvironment& env) : WApplication(env) and put in the example from the Wt::Json example

HelloApplication::HelloApplication(const WEnvironment& env)
  : WApplication(env)
{
    Json::Object result;
    Json::parse("{ "
             "  \"a\": \"That's great\", "
             "  \"b\": true "
             "}",
             result);

    std::cerr << "Size: " << result.size(); << std::endl; // Size: 2
    WString s = result.get("a");
    bool b = result.get("b");
    std::cerr << "a: " << s << ", b: " << b << std::endl; // a: That's great, b: true
}

I'm new to c++, so I have almost no idea what I'm doing. All I can do is execute the simplest of c++ files.

Here's the original source to the hello world file.

Here's where I got the json sample from.

** Repercussions**

Wow, my respect level just went through the roof for the power of c++.

This has totally destroyed my VPS. I can't restart. I can't even reinstall my distro.

When I finally go into production, I think I'm going to set up a totally different dev system to prevent something like this killing my production system.

Answer

Rainer Gl&#252;ge picture Rainer Glüge · Jan 17, 2019

As a potential quick fix: You can reduce the memory usage by doing

make -j 1

which tells the build tool to use only one CPU. Worked for me.