When a process runs out of memory, the process often ends. On AIX systems, the system error log might indicate that the process ended due to memory allocation failure. Use the following command to display the error log
errpt -a | more
On UNIX systems, each user can either inherit resource limits from the root user or have specific limits defined. The most useful setting to use for the process size limits is unlimited. That way, the system process size limits are defined to allow the maximum process growth.
On AIX systems, the number of data segments that a process is allowed to use also limits the process memory size. The default number of data segments is 1. The size of a data segment is 256 MB. Data segments are shared for both data and stack. The maximum number of data segments a process can use is 8
On AIX, the number of segments that a process can use for data is controlled by the LDR_CNTRL environment variable. It is defined in the parent process of the process that is to be affected. For example, the following example defines one additional data segment:
Symmetric Ciphers Functions Provided: Encryption and Decryption.
They are known as Symmetric because both the sender and the receiver share the same key to encrypt and then decrypt the data. The main function is to provide Confidentiality. e.g. Say Alice needs to send Bob a confidential document. She would encrypt the document using a symmetric cipher and a key and send it to Bob. Anybody looking at the message enroute to Bob will only see sequence of bytes. Bob on receiving the message will use the same key and the decrypt function of the symmetric cipher used by Alice to produce the original message. Few Symmetric Ciphers are: rotate cipher, Caeser cipher etc.
Disadvantages: 1. The key has to transferred to Bob through a separate communication channel which has to be secure. Then the question arises, if we have a secure communication channel, then why not send the document through that secure channel. 2. If Alice needs to send the document to 100 people, then she would have to use 100 different keys and encrypt the message 100 times and share them across.
Here the variable type is initialised using the default ctor MyType::MyType();
This looks like a variable declaration, but it's a function declaration for a function type that takes no parameters and returns a MyType.
This is direct initialization. The variable type is initialized using MyType::MyType(u);
This is copy initialization and the variable type is always initialized using MyType's copy ctor. Even though there is an '=' sign, this is a copy initialization and not an assignment. The form MyType type(u) should be preferred. It always works where 'MyType type = u' works and has other advantages e.g (It can take multiple parameters)
Output: $ ./a.exe
Calling Constructor 1
Name is = pankaj Age is = 10
Calling Constructor 3
Name is = pankaj Age is = 10
Calling Constructor 2
Calling Constructor 3
Name is = Anky Age is = 50
Here, MyType a = b; also calls the Constructor 3
Output: $ ./a.exe
Calling Constructor 1
Name is = pankaj Age is = 10
Calling Constructor 2
Name is = Anky Age is = 50
Here MyType a = b; works even when Constructor 3 is commented out because a default copy constructor is created for you when you don't specify one yourself. In such case, the default copy constructor will simply do a bitwise copy for primitives (including pointers) and for objects types call their copy constructor. If in the later case, a copy constructor is not explicitly defined then, in turn, a default copy constructor will be implicitly created.
Read more ...
According to 80-20 Rule: Look for that 20% of the code where your program spends 80% of it's time e.g. The HTTP specification is a 100 page document that describes all possible HTTP requests that a web server must handle.Most of the HTTP requests that traverse through the web are very simple. They contain only a small subset of the possible HTTP headers that a request can possibly contain.
Since Microsoft and Netscape have a dominating share of the browser market, all you need to do is peek at the request headers sent by these two browsers. This is yet another manifestation of the 80-20 rule—20% of your possible inputs will occur 80% of the time. An efficient use of programmer resources is to tune those 20% of the request types that appear 80% of the time. The HTTP Accept header is part of an HTTP request. It specifies what document formats are acceptable to the browser. The HTTP specification allows for the Accept header to have any combination of upper and lowercase. When you read a string token and want to determine if it is the Accept header, it is not enough to perform
We need to perform a case-sensitive string compare. We implemented a home-grown version for a casesensitive string-compare:
To be HTTP compliant, the correct action should be
However, memCaseCmp() is not cheap. It needs to uppercase both strings and then call memcmp(). This is where our domain expertise must come into play. Like we said, Microsoft and Netscape have a commanding share of the browser market. The Accept header they send happens to be "Accept:". This is only one of the many upper- and lowercase combination that HTTP allows, but it is the one we are going to receive 95% of the time, so it is the one we care about. The following test tries to take advantage of that:
In 95% of the inputs, the memcmp() test is going to succeed, and we will never call the more expensive memCaseCmp().
Read more ...
If we do not explicitly define constructors, then the compiler will generate the default constructor for us. The compiler-created default constructor is known as Synthesised Default Constructor.
It initializes each member using the same rules as are applied for variable initializations. Because the synthesised constructor does not automatically initialise the members of build-in type, we have to define the default Constructor explicitely. Bugs due to uninitialised variables can be hard to find.
Unitialised variables cause Run-Time problems as no compiler can detect all uses of uninitialised variables.
Read more ...