Understanding memory management in mingw / g ++

I was given the task of explaining this mainly. I took a quick look at the compiler documentation and it seems to be a good place to start, although it is quite extensive and I have little time. I would like to know if I need to understand C99 standards in advance, or if there is another good source I can check. I'll use it with Windows if that matters. I also understand simple concepts like heaps, stacks, links and more.

0


source to share


4 answers


AFAIK, g ++ is just a C / C ++ compiler, nothing more. memory is managed according to the C / C ++ standard libraries.



+2


source


Any decent C / C ++ tutorial should provide the basics for this information, but memory management in C / C ++ is a huge topic . Of course, for an entry-level class, your instructor would provide some guidance and probably a more specific, less open-ended question.



+1


source


g ++ is just a compiler. It follows the rules of the language it compiles (in the case of g ++, C ++, but you also mention C99).

And for your fairly specific questions, you might need

  • Refer to the standard language (for C ++ this is ISO / IEC 14882). Not free, unfortunately, but you can find drafts online for free that are basically as good as the real thing. The latest official version is C ++ 2003 (ISO / IEC 14882-2003) but contains only minor changes from the '89 original. C ++ 09 is also nearing completion and again drafts are available for that. Be careful, but this is hard reading and I would not recommend finding anything there if you are already very familiar with the language.
  • Analyze the assembler code the compiler generates. The standard leaves a lot up to implementation, so the only way to know how g ++ specifically pushes things onto the stack, in which order, etc., is by parsing the code it generates. (Note also that this may be different versions of g ++)

C ++ is a notorious language. There are huge chunks that are simply not covered by the standard and where the compiler can do what it likes. This makes it a bit tricky to figure out exactly what a given compiler is doing under the hood.

For this reason, you also need to make sure you know exactly what is expected of you. Learn what the language says about memory management, or how g ++ specifically works?

0


source


I don't understand this question. If "to understand memory management in mingw / g ++" means "to understand how the mingw g ++ compiler handles internal memory when it compiles files, such as when it allocates and frees abstract syntax tree nodes, etc." ) Then your answer is this: since the multi-pass GCC compiler may not know the optimal lifetime for any particular piece of data, but it knows that large groups of objects will not be needed from one pass to the next, so it uses memory pools when possible , and garbage collection elsewhere .

On the other hand, if you are asking how "how / when / what order ... objects, functions, variables, etc. are pushed onto the stack ... what is allocated and when and how it affects performance" then you there will be a long night slipping through the code.

0


source







All Articles