Skip to main content
6 events
when toggle format what by license comment
Nov 9, 2016 at 1:05 vote accept Dat Ha
Dec 2, 2016 at 21:02
Oct 15, 2016 at 0:21 comment added JRobert ... Then there is the additional memory (two more bytes) for the pointer), but the pointer's memory is only reserved while the called function is running. The array itself is only reserved while the caller (and thus the called) function is active. When the caller returns to its caller, the array space becomes free. So which uses less memory? It depends on when you look!
Oct 15, 2016 at 0:21 comment added JRobert Making the array global and letting both functions (caller and called) assume the use of that array, only requres the space for the 3 ints (6 bytes) but they remain reserved for the purpose for the entire program run, whether they are in use or not. The other option is for the caller to allocate the array memory in its own stack and pass the called function a pointer to it. That uses not only the three ints but possibly, memory for the pointer as well (unless the compiler chooses to pass the pointer in registers - but lets assume worst case - that it gets passed in stack memory). ...
Oct 14, 2016 at 21:04 comment added Dat Ha Which of those would use the less memory possible?
Oct 14, 2016 at 21:01 vote accept Dat Ha
Oct 15, 2016 at 11:10
Oct 14, 2016 at 20:36 history answered Edgar Bonet CC BY-SA 3.0