Before reading this, please refer to the below link to know about Dynamic allocation in Java and Garbage Collector:
Why embedded systems usually do not use dynamic allocation?
Suppose you allocated the following 3 sections in the heap:
Section 1: 10 bytes (Allocated)
Section 2: 20 bytes (Allocated)
Section 3: 30 bytes (Allocated)
Then, section 2 is freed, After this:
- If you want to allocate a section of 10 bytes, you can allocate them in the place of section 2 since it is free now
- But, if you want to allocate 25 bytes, then you can not allocate them in section 2, as it is not big enough, hence, the new section will be allocated after section 3
Section 1: 10 bytes (Allocated)
Section 2: 20 bytes (Free)
Section 3: 30 bytes (Allocated)
Section 4: 25 bytes (Allocated)
So, the process of dynamic allocation include details and uncertainty that affects the real time performance of the embedded system. Hence, usually embedded systems do not use dynamic alloctions. (malloc - realloc - free)
No comments:
Post a Comment