Lets say I have a shared library in Linux, written in C, with a single function that simply returns the pointer to a string literal.
void *ReturnObject() {
return (void *)"\xFA\x03\x44\x10\xE0";
}
When this library is loaded by the host application at runtime and this function is called, is the returned pointer pointing to some place in RAM or to the binary file on disk? Is RAM ever involved in this situation other than storing the pointer itself?
I ask because I plan on implementing this sort of thing in my project and the string will be several megabytes in size, and I'm worried that this strategy will in some way consume an equal amount of RAM.
If it does eat up RAM, would closing the library connection after the host program is done with this function release that memory?