malloc(sizeof(int)) vs malloc(sizeof(int *)) vs (int *)malloc(sizeof(int))

malloc(sizeof(int)) means you are allocating space off the heap to store an int. You are reserving as many bytes as an int requires. This returns a value you should cast to int *. (A pointer to an int.) As some have noted, typical practice in C is to let implicit casting take care of this. malloc(sizeof(int*)) means you are allocating space off the heap … Read more

Difference between hive.tez.container.size and tez.task.resource.memory.mb

hive.tez.container.size This property specifies tez container size. Usually value of this property should be the same as or a small multiple (1 or 2 times that) of YARN container size yarn.scheduler.minimum-allocation-mb and should not exceed value of yarn.scheduler.maximum-allocation-mb. As a general rule don’t put value higher than memory per processor as you want 1 processor per container and … Read more

What is ‘PermSize’ in Java?

A quick definition of the “permanent generation”: “The permanent generation is used to hold reflective data of the VM itself such as class objects and method objects. These reflective objects are allocated directly into the permanent generation, and it is sized independently from the other generations.” [ref] In other words, this is where class definitions … Read more

Destructor for a doubly-linked list that points to its value

You need to pair each new with exactly one delete. That is, you probably don’t want to delete prev (this node already was deleted) but you want to delete value. Well, I’d embed the value into the object and not point to it: If the value absolutely needs to be a pointer, I’d use a std::unique_ptr<int> (or, if you need to use C++ 2003, a std::auto_ptr<int>).

Fatal error: Out of memory, but I do have plenty of memory (PHP)

I ran accross the same kind of problem with the server dying when trying to use the swap. This is because mod_php does not free memory ever. So Apache processes keep growing either reaching apache or PHP’s memory limit or, if there’s no limit, crashing the server. Restarting apache makes it to spawn new fresh slim … Read more

Fatal Error: Allowed Memory Size of 134217728 Bytes Exhausted (CodeIgniter + XML-RPC)

Changing the memory_limit by ini_set(‘memory_limit’, ‘-1′); is not a proper solution. Please don’t do that. Your PHP code may have a memory leak somewhere and you are telling the server to just use all the memory that it wants. You wouldn’t have fixed the problem at all. If you monitor your server, you will see that it is now probably using … Read more

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