--> Sayadasite

Multiple Ads

Search

Menu Bar

Content Writing

 

What Is Content Writing?

Content writing is the process of planning, creating, and editing written material for digital or print platforms, such as websites, blogs, and social media. Its primary purpose is to inform, engage, or entertain a targeted audience, while also promoting a brand or driving specific business actions. [1, 2, 3]


Key Content Formats

Content writing is a versatile field encompassing many styles and niches. Some of the most common formats include: [1, 2]

Blog Posts and Articles: Informative pieces designed to educate readers, drive website traffic, and answer common questions.

Website Copy: Text for landing pages, "About Us" sections, and product descriptions that guide visitors and build brand trust.

Social Media Captions: Short, engaging text for platforms like Instagram, LinkedIn, and X (formerly Twitter) to spark conversations.

Email Newsletters: Direct communication sent to subscribers to nurture relationships and announce updates.

Technical Writing & White Papers: In-depth, industry-specific documents used to explain complex concepts or solutions. [1, 2, 3, 4, 5, 6]


Essential Writing Skills

According to general consensus in writing communities, successful content writers typically master the following skills: [1, 2]

Clarity and Conciseness: Communicating ideas simply without unnecessary fluff.

SEO (Search Engine Optimization): Understanding how to organically integrate keywords so that your content ranks higher on search engines like Google.

Thorough Research: Verifying facts, statistics, and claims from credible sources to ensure your writing is trustworthy.

Adaptability: Shifting your tone and voice depending on the audience, platform, and brand guidelines. [1, 2, 3]


The Writing Process

Crafting effective content requires a structured approach. Most writers follow these fundamental steps: [1, 2]

Define the Goal: Determine exactly what you want the reader to do or learn.

Understand Your Audience: Develop a reader's persona so you can tailor your tone, style, and vocabulary.

Outline: Create a logical roadmap using headings and subheadings.

Draft: Write the initial content freely without worrying too much about perfection.

Edit and Proofread: Refine your work for flow, check for grammatical errors, and ensure it is free from typos. 


“What Is Content Writing? A Beginner’s Guide”

I remember the first time I heard the term content writing. It sounded confusing and a little intimidating. I assumed it was something only marketing professionals or experienced writers could do. As a beginner with no hands-on experience in digital marketing, I honestly felt like it wasn’t meant for someone like me.


But as I started learning, I realized how wrong that assumption was.


My First Understanding of Content Writing

Content writing is simply creating written content for the internet. That’s it. Nothing complicated.


Every time you read a blog post, scroll through an Instagram caption, or check a product description on a website, you’re consuming content written by someone. Content writing exists to share information, solve problems, and connect with people.


Once I understood this, content writing didn’t feel scary anymore — it felt achievable.


Where Do We See Content Writing Every Day?

Before learning about content writing, I never noticed how much of it surrounds us.


It’s in:


Blog posts we read on Google

Emails from brands

Social media captions

Product descriptions on shopping websites

Realizing this helped me understand that content writing isn’t about fancy words. It’s about clear communication.


Do You Really Need Special Skills?

This was my biggest question.


Get Charumathi Venkataraman’s stories in your inbox

Join Medium for free to get updates from this writer.


Enter your email

Subscribe


Remember me for faster sign in


The answer surprised me. You don’t need a degree, expensive courses, or years of experience. What you actually need is:


Basic writing skills

Willingness to learn

Patience with yourself

Consistency

I learned that good writing improves only by writing more — even when the first few pieces aren’t perfect.


Can Someone With Zero Experience Start?

Yes. I’m proof of that.


Like many beginners, I started with doubts and hesitation. But content writing welcomes beginners because you can write about what you’re learning, what you’re experiencing, and what you’re discovering along the way.


How I Finally Started Writing

I stopped waiting to “be ready” and did something simple:


I chose a topic I was learning

I wrote in my own words

I focused on being honest, not perfect

I published without overthinking

What I’ve Learned So Far

Content writing isn’t about being the best writer in the room. It’s about being helpful and real. People connect with honesty more than perfection.


If you’re thinking about starting content writing but feel unsure, remember this: every writer you admire once started with their first article too.


Final Thoughts

Content writing is one of the most beginner-fri

endly skills you can learn. You don’t need to know everything. You just need to begin.


The White Tiger Character List

Balram

Balram Halwai, the story's narrator, protagonist, and anti-hero, tells of his rise from village peasant to successful entrepreneur. He has a significant faith in his exceptionalism, thinking of himself as a "White Tiger" not tied to conventional morality or social expectations. It is through this alternate system that he is able to rearrange his life and identity. Balram's dark humor, cynicism, and perceptiveness form the lifeblood of The White Tiger.


Balram was born in the village of Laxmangarh, into a life he considers miserable. Despite his intelligence, he was forced to leave school early to work. Nevertheless, he continued educating himself by eavesdropping on conversations. As he progressed through the echelons of the underclass, eventually being hired as a driver for Mr. Ashok and the Stork, he developed a severe resentment against the upper classes, which eventually prompted him to murder Mr. Ashok.


His other aliases include Munna, the White Tiger, and Ashok Sharma.


Mr. Ashok

Ashok is Balram's principal master, the Stork's son, and the Mongoose's brother. Exceedingly handsome, Ashok is also generally kind and gentle to those around him. Unlike the other members of his family, he trusts Balram immensely, and the latter senses a strange, profound connection between them. Ashok is childlike, with a short attention span, and generally dislikes his family's business dealings. Ultimately, his strange connection to Balram is not enough to save his life when Balram decides to murder him.


Pinky Madam

Pinky Madam is Ashok's wife, and just as good-looking as her husband. Because of her background, she is never fully accepted by Ashok's family. She is demanding, capricious, and deeply unsatisfied with life in India, constantly hoping to return to America, and is generally cruel to Balram. She eventually leaves Ashok to return to New York, and shows a deep grief over the hit-and-run that proved the last nail in the coffin of their relationship.


Mr. Krishna

Krishna is Balram's teacher in Laxmangarh before Balram is pulled out of school by his family. He is responsible for giving Balram his first "real" name, but he generally proves himself emblematic of the corruption and inefficiency of Indian schools, since he embezzles the government funds allocated for uniforms and food.


Vikram

Vikram Halwei is Balram's father, a rickshaw puller. Though he is not as attentive a parent as might be desired, he works extremely hard to provide for his family. Balram frequently thinks of his father and the sacrifices he made, and uses that resentment to inspire the murder. Vikram eventually died of tuberculosis in a deteriorating village hospital, a fate which largely motivates Balram to improve his station in life.


Balram's mother

Balram's mother died when he was very young, and her funeral is one of his most vivid early memories. Her body was swallowed up by the dark mud of the Ganga River. His mother had a short, miserable life, and Kusum frequently disrespects her memory.


Kusum

Kusum is Balram's grandmother, and the matriarch of the family, ruling through fear. Intimidating and sly, she attempts to exert her power over Balram, ensuring that he send money home once he becomes a driver, and later trying to coerce him into marrying. She has a habit of rubbing her forearms when she feels happy, a trait that Balram frequently comments upon.


Kishan

Kishan is Balram's brother, who takes care of him in the wake of their father's death. He is a strong, father-like figure who has a formative effect on Balram's own development.


the Stork

The Stork, actual name Thakur Ramdev, is one of the Four Animals, the four landlords who control Laxmangarh. A fat man with a large mustache, he owns the river and collects taxes from fishermen and boaters. He is father to Ashok and Mukesh (the Mongoose). His highly unethical business practices involve bribing officials, evading taxes, and stealing coal from government mines.


the Wild Boar

The Wild Boar is one of the Four Animals, the four landlords who control Laxmangarh. He owns the best agricultural lands around the village. He has two protruding teeth that resemble the tusks of a boar.


the Buffalo

The Buffalo is one of the Four Animals, the four landlords who control Laxmangarh. He is considered the greediest of the four landlords. He owns and operates the rickshaws, and his son was kidnapped and killed by the Naxals, for which he visited retribution on the entire family of the servant who aided in that kidnapping.


the Raven

The Raven is one of the Four Animals, the four landlords who control Laxmangarh. He owns the worst land, the dry, rocky hillside around the fort, and charges the goatherds who use this land for their flocks to graze. He is called the Raven because he likes “dip his beak into the backsides” of the goatherds who can’t pay. (“Dipping one’s beak” is a sexual euphemism that Balram uses).


the Mongoose

The Mongoose, actual name Mukesh Sir, is one of the Four Animals, the four landlords who control Laxmangarh. He is the Stork's son and Ashok's brother. A much worse man than Ashok, he does not question the family's business practices and condemns Ashok's interest in the American way of life. Mukesh is favored by the Stork and has more influence in the family than Ashok does.


Ram Persad

Ram Persad was the Stork's primary driver - and hence in charge of the Honda City - until Balram discovered that Ram was a Muslim and used that information to take control. After his secret is discovered, Ram Persad disappears without a word.


Vijay

Vijay is Balram's childhood hero, his model of a man who improved his station in life by forging his own identity. The son of a pig herder, Vijay's first success came with becoming a bus conductor. Balram and the other village boys admire his prestigious job and his uniform. Later, Vijay enters politics and quickly rises in the ranks. By the end of the narrative, Vijay is a powerful politician, just as corrupt and power-hungry as any of the rich elites in the novel.


Great Socialist

The Great Socialist is a powerful politician who controls the Darkness with the help of corruption and election fraud. He is described as having “puffy cheeks, spiky white hair” and “thick gold earrings” (86). People disagree as to whether he was always corrupt or if he began his political career with good intentions. Though his character essentially serves as an amalgam of typical corrupt Indian politicians, he is believed to be based on the actual politician Lalu Prasad Yadav.


Vitiligo-Lips

Vitiligo-Lips is one of the other drivers Balram encounters in Delhi. His lips are marked by vitiligo, a skin disease that affects many poor people in India and causes a lightening of skin pigment. Vitiligo-Lips serves as a sort of guide to Balram in Delhi, introducing him to city life, answering his many questions, and giving him access to a variety of illicit products ranging from Murder Weekly magazines to prostitutes. Since most of the other chauffeurs and servants in Delhi mercilessly tease Balram and make him an outcast, Vitiligo-Lips is crucial to Balram's survival.


Dharam

Dharam is a young relative of Balram's, sent to Balram by the family so he can be taken care of. Dharam is a sweet and obedient boy. Balram brings Dharam with him after the murder, and the two live together in Bangalore.


Ms. Uma

Ms. Uma is a former lover of Mr. Ashok's; he reconnects with her after Pinky Madam leaves. Though she begs him to marry her, Mr. Ashok is anxious about reintroducing her to his family. She is indifferent towards Balram, and ultimately plants the idea of replacing him into Ashok's head. Balram considers her a bad influence on his master.


Balram's family

Balram has countless aunts, uncles, cousins, nieces and nephews living in Laxmangarh. The family is very poor and traditional. Men and women sleep in opposite corners of the house. The most cherished member of the family is the water buffalo, who is kept fat and healthy and provides milk. Balram frequently feels guilty because Ashok's murder likely caused the death and torture of Balram's family.


Wen Jiabao

Wen Jiabao is the Premier of China, to whom Balram addresses the letters that narrate the story.


Dilip

Dilip is a cousin of Balram and Kishan; he accompanies them when they move to Dhanbad.


Ram Bahadur

Ram Bahadur is the Stork's head servant at his mansion in Dhanbad. A cruel Nepali with little concern for Balram, he is blackmailed into making Balram head driver after Balram discovers that Ram Bahadur must have kept Ram Persad's secret.


the minister's assistant

The minister's assistant, Mukeshan, frequently takes advantage of Ashok when the latter comes to bribe his boss.


Anastasia

Anastasis is the prostitute Balram hires, hoping she will be like Kim Basinger, as Mr. Ashok's prostitute was. When he discovers that her blond hair is only dyed, he grows angry, and is assaulted by the manager.


the manager

Anastasia's pimp is called "the manager." He assaults Balram after he screams at Anastasia.


Muslim shopowner

The Muslim shopowner in the secondhand book market of Old Delhi introduces Balram to Iqbal and the other great poets.


Ashok Sharma

Ashok Sharma is the final alias Balram takes for himself, after reaching Bangalore. It is obviously taken from his former master's name.


Mohammad Asif

Mohammad Asif works as a driver for Balram's company in Bangalore, a

nd hits a boy who is riding a bike. Balram has to bribe the police to remedy the situation.

The White Tiger

Summary 

The White Tiger, published in 2008, is Aravind Adiga's debut novel. In its first year of publication, it was named a New York Times Bestseller, and was awarded the Man Booker Prize, making Adiga the fourth Indian-born author and, at age 33, the second-youngest author overall to win the prize.

The novel explores class struggle in India at a time of modernization and globalization. Major transformations in Indian society have taken place in the last half-century, from the termination of British rule in 1947, to the end of the caste system, to the economic changes accompanying the rise of new industries such as technology and outsourcing. Adiga's The White Tiger rejects the typical "exoticized" view of India that is commonly represented in literature, with perhaps the most emblematic example being in the stories of Rudyard Kipling. Instead, the novel provides a darkly comic examination of the complications that have emerged during this period of transformation and upheaval.

The White Tiger Summary

The White Tiger is the story of Balram Halwai’s life as a self-declared “self-made entrepreneur”: a rickshaw driver’s son who skillfully climbs India’s social ladder to become a chauffer and later a successful businessman. Balram recounts his life story in a letter to visiting Chinese official Premier Wen Jiabao, with the goal of educating the premier about entrepreneurship in India.

Balram writes from his luxurious office in the city of Bangalore, but the story begins in his rural ancestral village of Laxmangahr. Throughout his childhood, Balram’s destitute family lives at the mercy of four cruel, exploitative landlords, referred to as “The Animals”: The Raven, The Stork, The Buffalo, and The Wild Boar. Despite the difficult life he is born into, Balram excels in school. His academic potential and personal integrity distinguish him from his classmates, bringing him to the attention of a visiting school inspector who nicknames him “the White Tiger,” after the most rare and intelligent creature in the jungle.
Balram’s parents recognize his potential and want him to complete his education, but his grandmother Kusum removes him from school early on so that he can work to support the family. Balram is determined to continue his education however he can. When he and his brother Kishan begin working in a teashop in nearby Dhanbad, Balram neglects his duties and spends his days listening to customers’ conversations. He overhears one customer speaking wistfully about the high earnings and easy life that India’s private chauffeurs enjoy, and begs his grandmother to send him to driving school. Kusum agrees, but Balram must promise to send home his wages once he finds a job.

His training complete, Balram knocks on the doors of Dhanbad’s rich families, offering his services. By a stroke of luck, he arrives at the mansion of the Stork (one of Laxmangahr’s animal landlords) one day after the Stork’s son, Mr. Ashok, returns from America with his wife Pinky Madam. The family hires Balram to become Ashok’s driver. In reality, Balram is more of a general servant to the family, while another servant, Ram Persad, has the privilege of driving them.

Balram learns that the Stork’s family fortune comes from illegally selling coal out of government mines. They bribe ministers to turn a blind eye to their fraudulent business and allow the family to avoid paying income tax. Unfortunately, the family recently had a disagreement with the region’s ruling politician, referred to as the Great Socialist. The family dispatches Ashok and Pinky to Delhi, where Ashok will distribute more bribes to make amends. When Balram learns that the couple will need a driver in Delhi, he schemes to have Ram Persad dismissed, and goes in his place.

Once in Delhi, Balram witnesses Pinky and Ashok’s marriage rapidly fall apart. Pinky returns to the US and leaves her husband after she kills a young child in a drunken, hit-and-run accident. In her absence, Ashok goes out to bars and clubs, hiring a prostitute one night, and reconnecting with a former lover on another. Observing his master’s gradual corruption and driving him through Dehli’s seedier districts, Balram becomes disillusioned and resentful. Although Ashok is a relatively kind master, Balram realizes that whatever generosity Ashok has shown him is only a fraction of what he can afford. Ashok has no real interest in helping Balram achieve a better life, or in changing the status quo.

Balram plans to murder Ashok and escape with the bag of the money that he carries around the city to bribe politicians. In addition to the risk of being caught, Balram must contend with the logic of “the Rooster Coop”: the system of oppression in which India’s poor, including Balram himself, are trapped. Balram knows that if he kills Ashok, Ashok’s family will murder all his own relatives in Laxmangahr in retaliation. Balram is also held back by the arrival in Delhi of his young cousin Dharam, who Kusum sends from Dhanbad with the demand that Balram help raise him.

Balram finally resolves to proceed with the murder, using a weapon he has fashioned out of a broken liquor bottle. One day as he drives Ashok to deliver a particularly large bribe, Balram pretends that there is a mechanical problem with the car. He pulls over, convinces Ashok to kneel down and examine the wheel, then brings the broken bottle down on Ashok’s head. After killing his master, he returns to Ashok’s apartment, collects Dharam, and escapes with his young cousin to Bangalore.

Once Balram regains his nerves in Bangalore enough not to fear immediate capture, he begins wandering the city and listening to conversations in cafes –just as he did in the teashop in Dhanbad—to plan his next move. He soon learns that Bangalore’s business world revolves around outsourcing, and that many large technology companies work on a nocturnal schedule. Balram creates a taxi company called White Tiger Drivers to bring call center workers home safely at night, and the venture is an enormous success.

By the time he sits down to tell his story, Balram is a wealthy man who keeps to himself, still fearful that one day his crime will be discovered. However, he concludes his letter to Wen Jiabao claiming that even if he is found out, he will never regret his crime: it was worth committing simply because it enabled him to experience life as a free man rather than as a servant.


Monitoring.

Memory Monitoring in Linux, Understanding calloc(), Thrashing, Thrashing and Working Set Model,

Paging and Segmentation, Memory Management

Memory Monitoring in Linux

Memory monitoring means observing how RAM, swap, cache, and processes use memory in a Linux system.

It helps detect:

Memory leaks

High RAM usage

Thrashing

Swap overuse

Performance bottlenecks

Common Linux Memory Monitoring Tools

Tool

Purpose

free

Overall memory usage

top

Real-time process monitoring

htop

Interactive process monitor

vmstat

Virtual memory statistics

sar

Historical memory stats

ps

Process memory usage

/proc/meminfo

Detailed kernel memory info

pmap

Process memory map

smem

Accurate proportional memory

iotop

Detect swap/thrashing I/O

1. Using free

Command:

free -h

Example output:

              total   used   free   shared  buff/cache  available
Mem:           7.7G   2.1G   1.2G      200M       4.4G       5.0G
Swap:          2.0G   100M   1.9G

Important Columns

Column

Meaning

used

Currently used memory

free

Completely unused RAM

buff/cache

Kernel cache

available

Memory available to apps

2. Using top

Command:

top

Shows:

CPU usage

RAM usage

Running processes

Important fields:

Field

Meaning

%MEM

Process memory percentage

RES

Resident memory

VIRT

Virtual memory

SHR

Shared memory


📌 3. Using htop

Interactive version of top.

Install:

sudo apt install htop

Run:

htop

Features:

Colorful UI

Process tree

Easy sorting/filtering

4. Using vmstat

Command:

vmstat 1

Updates every second.

Important columns:

Column

Meaning

si

Swap in

so

Swap out

free

Free memory

us

User CPU

id

Idle CPU

Detecting Thrashing

High:

si

so

indicates excessive swapping.

5. /proc/meminfo

Command:

cat /proc/meminfo

Provides detailed memory statistics.

Useful fields:

MemAvailable

Cached

Buffers

SwapFree

6. Monitoring Specific Process Memory

Using ps

ps aux --sort=-%mem | head

Shows top memory-consuming processes.

Using pmap

pmap <PID>

Displays:

Memory map of process

7. Using smem

Better memory accounting.

Install:

sudo apt install smem

Run:

smem

Provides:

USS

PSS

RSS

📌 8. Historical Monitoring with sar

Install:

sudo apt install sysstat

View memory statistics:

sar -r

Useful for:

Performance analysis over time

9. Monitoring Swap Usage

Command:

swapon --show

or:

cat /proc/swaps

10. Detecting Memory Leaks

Signs:

Memory usage continuously increases

System slows over time

Swap usage rises

Tools:

valgrind

top

smem

Example:

valgrind ./program

Important Memory Metrics

Metric

Meaning

RSS

Physical RAM used

VSZ/VIRT

Virtual memory size

PSS

Shared memory proportion

Swap usage

Disk-backed memory

Page faults

Missing pages loaded

Understanding Linux Cache

Linux aggressively uses RAM for caching.

So:

High memory usage is often normal.

Cached memory can be reclaimed when needed.

Warning Signs

Symptom

Possible Cause

High swap activity

Low RAM

System freezes

Thrashing

OOM kills

Memory exhaustion

Constant page faults

Insufficient working set

Example Monitoring Workflow

Check free memory
       
Identify heavy processes
       
Check swap usage
       
Inspect page faults/swapping
       
Find leaks or bottlenecks


📌 Useful Real-Time Commands

Watch Memory Continuously

watch -n 1 free -h

Top Memory Processes

ps aux --sort=-rss | head

Page Fault Statistics

vmstat -s

Summary

Linux memory monitoring helps:

Optimize performance

Detect memory leaks

Prevent thrashing

Analyze swap activity

Core tools:

free

top

htop

vmstat

/proc/meminfo

sar

smem

are essential for system administration and debugging.

 

 

 

calloc()

 Understanding calloc() in C Standard Library

calloc() stands for:

Contiguous Allocation

It is used in C to dynamically allocate memory for multiple elements and initialize all bytes to zero.

Syntax

void *calloc(size_t num, size_t size);

Where:

num → number of elements

size → size of each element in bytes

Returns:

Pointer to allocated memory

NULL if allocation fails

Main Difference from malloc()

Function

Initialization

malloc()

Garbage values

calloc()

All bytes initialized to 0

Example

#include <stdio.h>
#include <stdlib.h>

int main() {
    int *arr;
    int i;

    arr = (int *)calloc(5, sizeof(int));

    if (arr == NULL) {
        printf("Memory allocation failed\n");
        return 1;
    }

    for(i = 0; i < 5; i++) {
        printf("%d ", arr[i]);
    }

    free(arr);

    return 0;
}

Output

0 0 0 0 0

Because calloc() initializes memory to zero.

Step-by-Step Explanation

1. Allocation

calloc(5, sizeof(int));

Requests memory for:

5 integers

each of size sizeof(int)

If int = 4 bytes:

5 × 4 = 20 bytes

2. Contiguous Memory

Memory layout:

+----+----+----+----+----+
| 0  | 0  | 0  | 0  | 0  |
+----+----+----+----+----+

All initialized to zero.

Internal Working

Simplified process:

calloc() request
       
Heap manager allocates block
       
Memory initialized to zero
       
Pointer returned

Equivalent Using malloc()

calloc() is roughly similar to:

ptr = malloc(num * size);
memset(ptr, 0, num * size);

But calloc() is often optimized internally.

malloc() vs calloc()

Feature

malloc()

calloc()

Arguments

1

2

Initialization

No

Yes (zero)

Speed

Slightly faster

Slightly slower

Usage

General allocation

Arrays/initialized memory

Example: Dynamic Array

int *marks;
marks = (int *)calloc(100, sizeof(int));

Allocates memory for:

100 integers

initialized to 0

Important Notes

Zero Initialization

For integers:

0

For pointers:

NULL (all bits zero on most systems)

For floating point:

0.0

Common Errors

1. Forgetting free()

free(arr);

Without freeing:

Memory leak occurs

2. Accessing Beyond Allocated Memory

arr[10] = 5;

when only 5 elements allocated → undefined behavior.


3. NULL Pointer Access

Always check:

if(arr == NULL)

Using with Structures

Example:

struct Student *s;
s = (struct Student *)calloc(1, sizeof(struct Student));

Useful because all fields start initialized to zero.

Best Practices

Check for NULL
Free memory after use
Use calloc() when zero initialization needed
Avoid out-of-bounds access

Real-Life Analogy

Imagine booking apartment rooms:

malloc():

Gives rooms with old items left inside.

calloc():

Gives freshly cleaned empty rooms.

Summary

calloc():

Dynamically allocates contiguous memory

Initializes memory to zero

Useful for arrays and structures

Safer than malloc() when initialization is needed

Formula:

free() in C, /proc/meminfo and Memory

free() in C

free() is used to release dynamically allocated memory back to the system.

It works with memory allocated using:

malloc()

calloc()

realloc()

Syntax

void free(void *ptr);

ptr → pointer to memory block previously allocated dynamically

Why free() is Important

Heap memory is not automatically released like stack memory.

If memory is not freed:

Memory leaks occur

Program memory usage keeps increasing

Example

#include <stdio.h>
#include <stdlib.h>
int main() {
    int *ptr;
    ptr = (int *)malloc(sizeof(int));

    if(ptr == NULL) {
        return 1;
    }

    *ptr = 100;

    printf("%d\n", *ptr);

    free(ptr);

    return 0;
}

What Happens Internally

malloc() allocates heap memory
       
Program uses memory
       
free() marks block as available
       
Allocator may reuse block later

Important:

Memory is returned to allocator/runtime

Not necessarily immediately returned to OS

Common Memory Errors

1. Memory Leak

int *p = malloc(100);
/* forgot free() */

Allocated memory becomes unreachable.

2. Dangling Pointer

free(p);
*p = 10;

Using freed memory → undefined behavior.

3. Double Free

free(p);
free(p);

Can crash program or corrupt heap.

Good Practice

free(p);
p = NULL;

Prevents accidental reuse.

/proc/meminfo in Linux

/proc/meminfo is a virtual file containing detailed memory statistics.

View it using:

cat /proc/meminfo

Example Output

MemTotal:       16384256 kB
MemFree:         2048000 kB
MemAvailable:    6200000 kB
Buffers:          300000 kB
Cached:          2500000 kB
SwapTotal:       2097148 kB
SwapFree:        1800000 kB

Important Fields

Field

Meaning

MemTotal

Total RAM

MemFree

Completely unused RAM

MemAvailable

Memory available for applications

Buffers

Kernel buffers

Cached

File cache memory

SwapTotal

Total swap space

SwapFree

Free swap space

Why Cached Memory Matters

Linux uses free RAM for caching files to improve performance.

So:

Low MemFree does NOT necessarily mean low memory.

MemAvailable is more useful.

Example Interpretation

MemTotal:      8 GB
MemAvailable:  5 GB

Meaning:

System can still provide ~5 GB without heavy swapping.

Relationship Between free() and System Memory

When a program calls free():

Program frees heap block
       
Allocator marks block reusable
       
Kernel memory statistics may change

However:

Freed memory may remain inside process heap

It may not immediately reduce MemFree

Modern allocators:

Reuse freed blocks efficiently

Viewing Memory Usage

free Command

free -h

Displays:

RAM

Used memory

Free memory

Swap

top

top

Shows:

Per-process memory usage

vmstat

vmstat

Displays:

Virtual memory statistics

Paging activity

Linux Memory Management Concepts

Heap Memory

Dynamic allocation (malloc/calloc) uses:

Process heap

Heap grows as needed.

Virtual Memory

Each process gets:

Virtual address space

Kernel maps:

Virtual pages → Physical frames

Page Faults

Accessing nonresident page:

Triggers page fault

Kernel loads page into RAM

Simplified Memory Flow

malloc()
  
Heap allocation
  
Program uses memory
  
free()
  
Memory reusable

Out of Memory (OOM)

If system memory exhausted:

Linux may invoke:

OOM Killer

to terminate processes.

Key Takeaways

free()

Releases dynamically allocated heap memory

Prevents memory leaks

Essential for long-running programs

/proc/meminfo

Provides detailed Linux memory statistics

Useful for monitoring RAM and swap usage

Linux Memory

Uses virtual memory

Employs paging and caching

Optimizes memory reuse dynamically