-bash: fork: Cannot allocate memory

I also faced this issue with my Ubuntu 14.04 desktop. Even these basic command showed Can’t allocate memory error. On investigating, found that system is using all the memory for Caching and is not freeing up memory. This is called Cache Ballooning and solved this by clearing the cache.

Is the sizeof(some pointer) always equal to four?

he guarantee you get is that sizeof(char) == 1. There are no other guarantees, including no guarantee that sizeof(int *) == sizeof(double *). In practice, pointers will be size 2 on a 16-bit system (if you can find one), 4 on a 32-bit system, and 8 on a 64-bit system, but there’s nothing to be gained in … Read more

Python/Numpy MemoryError

Rewrite to and this will use much less memory. Whereas p = p*alpha allocates a whole new matrix for the result of p*alpha and then discards the old p; p*= alpha does the same thing in place. In general, with big matrices, try to use op= assignment.

Difference between word addressable and byte addressable

A byte is a memory unit for storage A memory chip is full of such bytes. Memory units are addressable. That is the only way we can use memory. In reality, memory is only byte addressable. It means: A binary address always points to a single byte only. A word is just a group of bytes – 2, 4, 8 depending upon the data bus size of the CPU. To understand the memory operation fully, you must be familiar with the various registers of the CPU and the memory ports of the RAM. I assume … Read more

In Python, what is `sys.maxsize`?

Python can handle arbitrarily large integers in computation. Any integer too big to fit in 64 bits (or whatever the underlying hardware limit is) is handled in software. For that reason, Python 3 doesn’t have a sys.maxint constant. The value sys.maxsize, on the other hand, reports the platform’s pointer size, and that limits the size of Python’s data … Read more

memory error in python

This one here: seems to be very inefficient and expensive for large strings. Better do A buffer object keeps a reference to the original string and start and length attributes. This way, no unnecessary duplication of data occurs. A string of length l has l*l/2 sub strings of average length l/2, so the memory consumption would roughly be l*l*l/4. With a … Read more