| TIP: Click on subject to list as thread! | ANSI |
| echo: | |
|---|---|
| to: | |
| from: | |
| date: | |
| subject: | How is memory handled? |
Hello Neil! Replying to a message of Neil Heller to All: NH> If I were to create a variable, as such: NH> char * foo[] = "For whom the bell tolls"; NH> how does the heap memory get cleared where that static string is NH> located? Who said it was heap memory? The string "For whom the bell tolls" is not on the heap, nor on the stack. It is in read-only memory in the data segment of your executable, eligible to be shared amongst multiple invocations of your binary (executable or library). foo, being an array of pointers to char, is on the stack, with a single pointer to this read only memory. That pointer will get recycled when foo goes out of scope. The string, however, lives on until the termination and unloading of your program in all invocations. NH> If I were to create the variable as: NH> static char * foo[] = "For whom the bell tolls"; NH> would it be cleared any differently? foo would not be recycled until program termination. Darin ---* Origin: Tanktalus' Tower BBS (1:250/102) SEEN-BY: 633/267 270 @PATH: 250/102 99 10/345 379/1 633/267 |
|
| SOURCE: echomail via fidonet.ozzmosis.com | |
Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.