Garbage collection and memory management in Erlang

To classify things, lets define the memory layout and then talk about how GC works. Memory Layout In Erlang, each thread of execution is called a process. Each process has its own memory and that memory layout consists of three parts: Process Control Block, Stack and Heap. PCB: Process Control Block holds information like process … Read more

A dynamic buffer type in C++?

You want a std::vector: std::vector<char> myData; vector will automatically allocate and deallocate its memory for you. Use push_back to add new data (vector will resize for you if required), and the indexing operator [] to retrieve data. If at any point you can guess how much memory you’ll need, I suggest calling reserve so that … Read more

out of memory issue in installing packages on Ubuntu server

Extend your RAM by adding a swap file: http://www.cyberciti.biz/faq/linux-add-a-swap-file-howto/ a swap file is a file stored on the computer hard drive that is used as a temporary location to store information that is not currently being used by the computer RAM. By using a swap file a computer has the ability to use more memory … Read more

Memory usage of current process in C

The getrusage library function returns a structure containing a whole lot of data about the current process, including these: long ru_ixrss; /* integral shared memory size */ long ru_idrss; /* integral unshared data size */ long ru_isrss; /* integral unshared stack size */ However, the most up-to-date linux documentation says about these 3 fields (unmaintained) … Read more

How does kernel know, which pages in the virtual address space correspond to a swapped out physical page frame?

Linux: When swap file is used the Page Table Entry gets updated with one marked as invalid and holding information about where it is saved in the swap file. That is: an index to the swap_info array and an offset within the swap_map. Example from (an a bit old) Page Table Entry type (pte_t) on … Read more

How do I call the original “operator new” if I have overloaded it?

You can’t access them because it isn’t really overloading, it’s replacement. When you define your own ::operator new, the old one goes away. That’s pretty much that. Essentially, you need to call malloc from a custom ::operator new. Not only that, but also follow the directions in 18.4.1.1/4 to properly handle errors: Default behavior: — … Read more

How do Haskell compilers decide whether to allocate on the heap or the stack?

When you call a function like this f 42 (g x y) then the runtime behaviour is something like the following: p1 = malloc(2 * sizeof(Word)) p1[0] = &Tag_for_Int p1[1] = 42 p2 = malloc(3 * sizeof(Word)) p2[0] = &Code_for_g_x_y p2[1] = x p2[2] = y f(p1, p2) That is, arguments are usually passed as … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)