samedi 2 avril 2016

How to detect if an object is made up primarily of stack or dynamic memory

I've currently been working with a library that potentially creates heavy weight objects. Specifically, I'm creating objects that are associated with wave files.

Now when creating an instance of a Wave Object (just as an example), is there a good way to determine where it is being allocated in memory?

For example, if I were to instantiate a std::vector in the stack, I know that some memory is allocated on the stack (i.e. header information) and the actual container data is created on the heap. So for the most part, I don't have to worry about a stack memory overflow. Although I still have the option to fully instantiate the object in heap.

But let's say I don't know about an objects implementation. Let's say I'm using a library that creates a massive array in the stack. This could potentially cause problems.

So my question: how do we know how 'heavy' an object is memory wise?

Aucun commentaire:

Enregistrer un commentaire