Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
I wrote the following program to see what happens when pointers to the heap are created:
#include "mbed.h" class MyTest { public: char someData[0xFF]; }; MyTest* test(void); int main() { MyTest* B1; MyTest* B2; B1 = test(); B2 = test(); printf("Address of B1 is: %x\r\n", B1); printf("Address of B2 is: %x\r\n", B2); while(1) { } } MyTest* test(void) return new MyTest(); } The result of the program is: Address of B1 is: 10000260 Address of B2 is: 10000368It seems like B1 and B2 are placed directly after each other on the heap. One would expect that if the heap gets 'cleaned up', and the location of the objects are changed during this process ,the pointers will point to the wrong memory locations. This is not the case however. Does the processor use a hardware lookup table to get the memory pointed to by B1 and B2? i.e. are the addresses returned by the program virtual addresses?