Using the Free Command on Node Construction: Potential Risks and Solutions

  • Thread starter Thread starter transgalactic
  • Start date Start date
Join the discussion
Ask a follow-up here, or get your own question answered by working scientists, mathematicians and engineers — people, not an autocomplete.
Real named experts · corrections over time · the nuance an AI answer skips
1 reply · 2K views
transgalactic
Messages
1,386
Reaction score
0
do i have to use free command on each node i have constructed

will it damage my computer if i will leave it as it i now
(fill out my memory)
Reply With Quote
 
Physics news on Phys.org
I suppose you are writing code in C.
Any memory that you have assigned using malloc(), calloc() should be freed using the free() command when you no longer need it.
This includes memory that has been allocated by functions of the C-Library, such as strdup.
Yes, failing to free memory properly will cause a memory leak, i.e. fill up your memory unnecessarily.
If you want to do some reading on the subject, try:
http://www.yolinux.com/TUTORIALS/C++MemoryCorruptionAndMemoryLeaks.html
Also, if you are writing in C++, memory that you have assigned as objects of classes must be freed using the delete command.