My 10-year-old's concept of memory leaks

For everything that's not in any way related to PureBasic. General chat etc...
Dude
Addict
Addict
Posts: 1907
Joined: Mon Feb 16, 2015 2:49 pm

My 10-year-old's concept of memory leaks

Post by Dude »

I was talking to my 10-year-old son about programming, and how everything has to be in a specific sequence and that you can't leave any steps out. I then used the old "make me a peanut butter sandwich" analogy to demonstrate.

I asked him the exact steps required to make the sandwich. I prompted him with, "You open the fridge. Then what?" He said, "get the margarine, and open the pantry" (to get the peanut butter). But then he immediately said, "No, wait, close the fridge first and THEN open the pantry."

I was so proud of him and I explained that was correct because he just prevented a "memory leak". :lol: :wink:

I thought it was cool, anyway. :)
User avatar
TI-994A
Addict
Addict
Posts: 2751
Joined: Sat Feb 19, 2011 3:47 am
Location: Singapore
Contact:

Re: My 10-year-old's concept of memory leaks

Post by TI-994A »

Dude wrote:...then he immediately said, "No, wait, close the fridge first and THEN open the pantry."

...I explained that was correct because he just prevented a "memory leak".
Clearly a smart kid! :D

However, you might have given him the wrong idea. Memory leaks are not necessarily caused by sequence, but rather by failure to clean-up. It might be a drain on resources, but it would have been absolutely legal for him to close the fridge even after making the sandwich. :lol:
Texas Instruments TI-99/4A Home Computer: the first home computer with a 16bit processor, crammed into an 8bit architecture. Great hardware - Poor design - Wonderful BASIC engine. And it could talk too! Please visit my YouTube Channel :D
Dude
Addict
Addict
Posts: 1907
Joined: Mon Feb 16, 2015 2:49 pm

Re: My 10-year-old's concept of memory leaks

Post by Dude »

Very true! I prefer to close/free something as soon as it's no longer needed, though. :)
User avatar
TI-994A
Addict
Addict
Posts: 2751
Joined: Sat Feb 19, 2011 3:47 am
Location: Singapore
Contact:

Re: My 10-year-old's concept of memory leaks

Post by TI-994A »

Dude wrote:Very true! I prefer to close/free something as soon as it's no longer needed, though. :)
Best practices! :wink:
Texas Instruments TI-99/4A Home Computer: the first home computer with a 16bit processor, crammed into an 8bit architecture. Great hardware - Poor design - Wonderful BASIC engine. And it could talk too! Please visit my YouTube Channel :D
User avatar
Lunasole
Addict
Addict
Posts: 1091
Joined: Mon Oct 26, 2015 2:55 am
Location: UA
Contact:

Re: My 10-year-old's concept of memory leaks

Post by Lunasole »

Funny story. You're doing right btw, such analogies teaching child much better than dry theory (well, not childs only ^^), and they also involving abstract thinking
"W̷i̷s̷h̷i̷n̷g o̷n a s̷t̷a̷r"
normeus
Enthusiast
Enthusiast
Posts: 475
Joined: Fri Apr 20, 2012 8:09 pm
Contact:

Re: My 10-year-old's concept of memory leaks

Post by normeus »

I would call that open door, a power drain!
just because I am currently programming buggy xcode iPhones ! :D
google Translate;Makes my jokes fall flat- Fait mes blagues tombent à plat- Machte meine Witze verpuffen- Eh cumpari ci vo sunari
Mistrel
Addict
Addict
Posts: 3415
Joined: Sat Jun 30, 2007 8:04 pm

Re: My 10-year-old's concept of memory leaks

Post by Mistrel »

If you forget to close the fridge then all of the food (objects) inside will run out of cold air (memory) and expire (program crash). :wink:

I thought your story was cute.

I can still remember how hard it was for me to make the jump from a gosub with globals to functions with scope and a return value. I sat on the floor trying to figure it out for hours.
Post Reply