c - Proper use of malloc -
One chapter from the book I read is focused on the allocated memory management space using Malok Linux Functions.
Before I read it, I will make relatively small programs without the allocation of space.
Is it not acceptable to do anything in the manner of allocation for memory, whose memory footprint is below 50 MB? What are the consequences of doing this?
If you can do without malloc for small applications, maybe using the location of any stack There is no need to. Little utility programs or toy programs often do not. Whatever you want to use the heap, however, may be wrong to get by:
-
Arrays If you allocate large arrays to yourself, then this To make sure that everything is all right ', then you should probably use Maulok at least, to handle the situation of error, to check that they are actually very big. With dynamically allocated arrays, if you find that you need more space, then you can do a large number of flights.
-
Too much recursion is sometimes the advantage of getting out of the array to exit the array, because unlike the languages of the function, it does not properly adapt the things can. If you are getting your memory space by calling a lot of functions to make it, then it is very dangerous (the program may crash on you one day).
-
Using static pools of objects, squares). Maybe you can have a ring buffer and 15 objects, and you've allocated them statically because you know that there will not be more than 15 entries in your buffer, it's OK, but in more strokes created with Molok Allow buffer to grow, it can be good.
Perhaps under much more circumstances, the need to t malloc may benefit from it added.
Comments
Post a Comment