CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Dec 2005
    Posts
    114

    Help with the heap

    I have written two classes: GHeap_Block and GHeap, in which I assuage the task of handling heaps. One of the GHeap constructors enables the creation of an ever-growing heap. Whenever the number of bytes in a heap block dependent upon a heap exceeds its size Windows automatically allocates more memory for the heap. However, it has come to my attention that when a heap_block is freed, the memory it occupied is still allocated by the heap. Thus, the heap is ever growing. Is there any way in which I can make it so that the heap shrinks at the appropriate time?

    BTW, originally I accidently titled this, "Does the heap ever sleep?" I did not intend to title it that. I tried to change it to, "Help with the heap"
    Last edited by Guidosoft; August 20th, 2006 at 12:12 PM. Reason: Accident in the title.

  2. #2
    Join Date
    Feb 2003
    Location
    Iasi - Romania
    Posts
    8,234

    Re: Help with the heap

    Quote Originally Posted by Guidosoft
    BTW, originally I accidently titled this, "Does the heap ever sleep?" I did not intend to title it that. I tried to change it to, "Help with the heap"
    Done... title changed.
    Ovidiu
    "When in Rome, do as Romans do."
    My latest articles: https://codexpertro.wordpress.com/

  3. #3
    Join Date
    Aug 2000
    Location
    New York, NY, USA
    Posts
    5,656

    Re: Help with the heap

    Quote Originally Posted by Guidosoft
    IIs there any way in which I can make it so that the heap shrinks at the appropriate time?
    HeapCompact

    The HeapCompact function attempts to compact a specified heap. It compacts the heap by coalescing adjacent free blocks of memory and decommitting large free blocks of memory.


    SIZE_T HeapCompact(
    HANDLE hHeap,
    DWORD dwFlags
    );
    Vlad - MS MVP [2007 - 2012] - www.FeinSoftware.com
    Convenience and productivity tools for Microsoft Visual Studio:
    FeinWindows - replacement windows manager for Visual Studio, and more...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured