- release the allocated memory.
- free the allocated memory.
- delete the allocated memory.
What are the differences between them?
English Language & Usage Stack Exchange is a question and answer site for linguists, etymologists, and serious English language enthusiasts. It only takes a minute to sign up.Sign up to join this community
Well, the differences have more to do with the computer language behind them. Delete is inappropriate. Assuming C++ or similar, an object is being deleted, and its associated memory is automatically freed thereafter. Free will be understood by any C-family programmer. Release probably will be too but when you are writing for a C audience, stick with C terminology. (Release is more often used with respect to a connection pool, an OS resource, but not memory—in C. In another language, your mileage may vary.)
Generally memory allocation in programming languages operates in pairs of functions, and as Andrew Lazarus states, this depends on the language in question. Manual memory management is most common in C-style languages, while many others (including Java) have automatic management through garbage collection etc, so the programmer has not to worry about allocating or deallocating memory.
In C the functions are
free() (there are different variants for allocation, eg
calloc()). So here you would definitely use the second statement, to free allocated memory.
Objective-C uses mostly reference counting (which in the current version is done automatically), and here you create objects using
[[MyClass alloc] init], or short
[MyClass new] (though this is not conventionally used). Note that this is about objects, not 'raw' memory. For memory you'd use the C functions. When you want to keep a handle to an object alive you call
[myObject retain] which adds one to the object's reference count, and to get rid of it you call
[myObject release]. Once there are no references to an object it is deallocated, and it's memory freed. So here you would almost use the first statement, but for an object which is released.
In C++ you create objects with
new and delete them with
delete (last time I did this—I have not used C++ for a long time). Again you delete an object, not memory.
In a language-agnostic context I would say the first two (release/free) are mostly synonymous, while I would not use the third one at all.