+ 1

What happen when use dynamic memory in different programming language?

24th Apr 2017, 9:12 PM
LoveLearn
LoveLearn - avatar
6 ответов
+ 1
but in c there are problems from heap such as fragmantation so what we do to overcome this?
26th Apr 2017, 10:34 AM
LoveLearn
LoveLearn - avatar
+ 1
Good question! You must be doing some embedded programming if you're worried about this. What you are looking for is a memory pool. The details are more than I can get into here but the basic idea is that you allocate a block of memory (usually the size of the heap so any other allocations fail) and then assign blocks of memory to the pool. Usually implementations include FIFO block allocation or a lifetime allocation with semaphore access.
26th Apr 2017, 4:15 PM
Mason Krei
Mason Krei - avatar
+ 1
Did this answer your question? Use the check mark next to my response that marks it as the answer. Thank you.
28th Apr 2017, 5:26 PM
Mason Krei
Mason Krei - avatar
0
In all languages dynamic memory is allocated to the heap. In C any allocated memory must be manually deallocated. In C++ well designed code should deallocate memory when allocated memory falls out-of-scope (see RAII and smart pointers). In C# and Java nearly everything is allocated to the heap and the virtual machine's garbage collector deallocates unused heap space in blocks.
25th Apr 2017, 3:25 PM
Mason Krei
Mason Krei - avatar
0
can you please give me link to do that? link ? code? any help
27th Apr 2017, 12:36 AM
LoveLearn
LoveLearn - avatar