Shadowing Practice: You are wasting memory - Learn English Speaking with Video

Creating lesson...
1
Take a look at this C code and tell me what the output of that printf will be.
2
If you said 12, you are correct, and that's because each integer is 4 bytes wide.
3
Now, what happens if I add a character to the structure?
4
You probably already know that a character has a size of 1 byte, but if we run this program, we can see that the structure became 16 bytes.
5
This happens because of memory alignment.
6
You can imagine memory as a row of numbered boxes, where each number represents an address.
7
Each box can hold exactly one byte.
8
We know that on 64-bit machines an integer is usually four bytes.
9
For it to be aligned, its address must be a multiple of its size.
10
If a value is not aligned, on some architectures and older computers, working with it might be slower.
11
But how is the structure represented in memory by the compiler?
12
The structure is represented as a series of consecutive values, each starting at a specific padding from the beginning of of the structure.
13
The padding is needed so that each value is correctly aligned.
14
As you can see here, the value D would occupy only one byte, but three extra bytes are added so that the value C is correctly aligned.
15
If we add another character at the end of the structure, another 3 bytes of padding are added because the whole structure must be aligned to the alignment of the structure itself,
16
which is the maximum alignment between the members of the structure.
17
This way, when creating an array of this structure, the first member is always correctly aligned.
18
So to save memory, we can move our characters close together
19
so that only 2 bytes of padding are added making the whole thing 16 bytes instead of 20, while keeping everything correctly aligned.
20
We can check that in C as well.
21
As you can see, this code represents what was shown in the previous images.
22
Now take a look at the output of this.
23
If we move E, like this, the output changes.
24
Now if you want to ignore alignment and remove padding for some reason, you can use the packed attribute like this on GCC and CLang and the compiler will not insert any padding,
25
as you can see here from this output, but note that on some architectures this might make the code slower.
26
So in conclusion, if you don't wanna waste memory over padding, remember to place your structural members correctly.
27
Bye!

Context & Background

In this video, the speaker discusses an essential concept in programming related to memory management, specifically within the C language. The focus is on how memory is allocated and the importance of memory alignment for optimizing performance. This topic introduces technical vocabulary that can be significant for learners interested in not only the English language but also in programming and computer science. Understanding these concepts can help enhance vocabulary and comprehension, particularly for those engaged in technical fields.

Top 5 Phrases for Daily Communication

  • "Take a look at this C code." - A common introductory phrase that invites attention.
  • "If you said 12, you are correct." - Engaging the audience by affirming their response encourages participation.
  • "For it to be aligned." - This phrase highlights the necessity of proper arrangement, applicable in many contexts.
  • "This happens because of memory alignment." - A phrase explaining cause and effect, useful in technical discussions.
  • "To save memory, we can move our characters close together." - This practical phrase offers a solution, important for effective communication.

Step-by-step Shadowing Guide

If you're looking to improve your English speaking skills using this video, consider employing the shadowing technique. This method involves listening to the speaker and simultaneously repeating what they say, which can significantly enhance your pronunciation and fluency. Follow these steps:

  1. Watch the video once without pausing: Get a general idea of the content and the speaker's tone.
  2. Identify challenging phrases: Focus on phrases that might be difficult to pronounce or understand, such as "memory alignment" or "padding."
  3. Play small segments at a time: Start with a short clip, pausing after each sentence to repeat aloud.
  4. Focus on intonation and rhythm: Pay attention to how the speaker emphasizes certain words to capture the natural flow of speech.
  5. Record yourself: Use a shadowing site or app to record your speech. Comparing your recording to the original can help you identify areas for improvement.

By following this method, you not only hone your listening skills but also boost your speaking confidence. Whether you want to learn English with YouTube or improve technical vocabulary, the shadow speech you practice will be invaluable. With consistent practice, you'll find yourself becoming comfortable with both the language and the technical concepts discussed.

What is the Shadowing Technique?

Shadowing is a science-backed language learning technique originally developed for professional interpreter training and popularized by polyglot Dr. Alexander Arguelles. The method is simple but powerful: you listen to native English audio and immediately repeat it out loud — like a shadow following the speaker with just a 1–2 second delay. Unlike passive listening or grammar drills, shadowing forces your brain and mouth muscles to simultaneously process and reproduce real speech patterns. Research shows it significantly improves pronunciation accuracy, intonation, rhythm, connected speech, listening comprehension, and speaking fluency — making it one of the most effective methods for IELTS Speaking preparation and real-world English communication.