none
memory setting, MFC CArray uses stack or heap?

    Question

  • Hello,

    in my MFC MDI application I use many CArrays holding a lot of data.
    I recognized that after 60 to 70 MB of allocated memory of my Programme (shown in Task Manager), I cannot increase the memory usage. That means, I cannot load more data.

    In my project linker settings I only set the stack reserve size to 8000000 (roughly 7.5 MB).

    1. I want to know if CArray uses the stack or the heap memory?

    2. How can I get more memory so that my programme can load more data?

    Thanks, Guido

    Thursday, December 07, 2017 8:22 AM

Answers


  • 1. I want to know if CArray uses the stack or the heap memory?


    Heap.

    >I cannot increase the memory usage. That means, I cannot load more data.

    How are you determining that you can't use more memory?

    What are the symptoms? Is it failing when trying to crete a new CArray?
    Or when trying to expand an existing CArray? Other?

    Which version of VC++ are you using?

    - Wayne

    • Marked as answer by Guido Franzke Thursday, December 07, 2017 1:52 PM
    Thursday, December 07, 2017 9:46 AM

All replies


  • 1. I want to know if CArray uses the stack or the heap memory?


    Heap.

    >I cannot increase the memory usage. That means, I cannot load more data.

    How are you determining that you can't use more memory?

    What are the symptoms? Is it failing when trying to crete a new CArray?
    Or when trying to expand an existing CArray? Other?

    Which version of VC++ are you using?

    - Wayne

    • Marked as answer by Guido Franzke Thursday, December 07, 2017 1:52 PM
    Thursday, December 07, 2017 9:46 AM

  • >I cannot increase the memory usage. That means, I cannot load more data.

    How are you determining that you can't use more memory?

    What are the symptoms? Is it failing when trying to crete a new CArray?
    Or when trying to expand an existing CArray? Other?

    Which version of VC++ are you using?

    - Wayne

    Thanks for your quick answer.

    I use Microsoft Visual C++ 2015, Version 14.0.25431.01 Update 3 on Windows 10 with 16 GB RAM and 10 GB free memory. But it happens on Windows 2012 Server with 24 GB and 11 GB free memory too.

    In my MDI application, I open a child frame and load data into its document. After I have opened many child windows and want to open one more child, the child does not open. There is no error message. If I close one old child window and open the new child that didn't open before, it opens correctly.

    It's not because of the amount how many child windows I have opened, because it differs from how much data is in one child document. I think it is because of memory consumption.

    You say, CArray uses the heap, so I think the problem must be something else.

    How much heap can I use? Can I increase the memory for my application?

    Thanks, Guido

    Thursday, December 07, 2017 10:02 AM
  • Check the GDI handle count of your running app. The default limit is 10,000.
    You can see this in Task Manager, Details tab, GDI Objects column.

    -Seetharam

    Friday, December 08, 2017 2:52 AM