| Summary: | /bin/echo utility does not free() the memory which allocated by malloc() | ||
|---|---|---|---|
| Product: | Base System | Reporter: | by <by> |
| Component: | bin | Assignee: | freebsd-bugs (Nobody) <bugs> |
| Status: | Closed Works As Intended | ||
| Severity: | Affects Many People | CC: | maxim, ngie |
| Priority: | --- | ||
| Version: | 10.3-RELEASE | ||
| Hardware: | Any | ||
| OS: | Any | ||
|
Description
by
2017-01-04 03:10:35 UTC
Hello, this is quite ok to not bother to free(3) dynamically allocated memory if the program is going to exit 20 lines of code later. No bug here actually. (In reply to Maxim Konovalov from comment #1) Hi, I have not learned that the process termination will free the heap memory. Does this specially on FreeBSD or any convention I need to learn? If you can give me some tips, I will be very appreciated. Thanks, by Hello, This is not specific to FreeBSD. Upon process termination, both voluntary or involuntary, the whole address space including the heap of the process is destroyed. So, it is quite common for simple utilities like echo(1) with short life cycle to rely on this. I think pretty much any book of unix programming covers that. My personal recommendation is Steven's "Advanced programming in the UNIX environment" aka APUE. I'm going to close this ticket unless you have any concerns. Maxim Hi, Okay, I am clear now. You can close this ticket. Thanks for your explanation. By the way, I am reading APUE book now, maybe I need investigate more about this. by Closed at submitter's request. |