Skip to main content

Posts

Memory Leak

Memory Pools are just a section of memory reserved for allocating temporarily to other parts of the application. So, memory leak occurs when you allocate some memory from the heap(or a pool) and then delete all references to that memory without returning it to the pool it was allocated from. Basically, we are left with less memory to allocate because we have not freed the memory and keep on allocating it.

Structure padding

Structure Padding Most processors require specific memory alignment on variables certain types. Normally the minimum alignment is the size of the basic type in question, fo instance this is common char variables can be byte aligned and appear at any byte boundary short (2 byte) variables must be 2 byte aligned, they can appear at any even byte boundary. This means that 0x10004567 is not a valid location for a short variable but 0x10004566 is. long (4 byte) variables must be 4 byte aligned, they can only appear at byte boundarys that are a multiple of 4 bytes. This means that 0x10004566 is not a valid location for a long variable but 0x10004568 is. Structure padding occurs because the members of the structure must appear at the correect byte boundary, to achieve this the compiler puts in padding bytes (or bits if bit fields are in use) so that the structure members appear in the correct location. e.g. struct ex{ int i; //assuming int to take 2 bytes char c; int j; }; Here, size of struc...

Scala Programming Beginner : Error

How to start with scala? Don't forget to install java in your system first. 1) Download Scala from sourceforge.net 2) Extract binaries 3) set path in environment variable for scala -> Add path of scala/bin in 'path' variable list. 4) Add new variable Scala_Home and value as path of scala directory. 5) Test in cmd by writing 'scalac'. Note: if it gives error java.exe was unexpected at this time, then remove Java_Home variable from your environment variables, then again check with 'scalac'.

Secure Http

The site can be hosted using secure version of http also, i.e., HTTPS. It sends the information in encrypted form so it's secure. It uses SSL and sends through port number 443 instead of port 80. requires a license/certificate to be purchased to host the site using secured version, i.e., HTTPS.

Handshake in TCP

3 way Handshake: When TCP establishes the connection. Steps followed: 1) SYN packet is sent by A to B with a random sequence number(for initial seq. no.), say SYN 1000 as a request to establish the connection. 2) B sends ACK 1001 indicating to send the packet 1001 assuring the request to be accepted. 3) A sends ACK 1001 to indicate that it has received the request confirmation. 4 Way Handshake: When there's a connection termination then 4 way handshake is used. For termintation of connection in one direction: 1) FIN packet is sent 2) Other party acknowledges it Similar process is followed for connection to end the other way as it's a full duplex connection.