CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4

Thread: glNewList allocates 260KB!!!!

  1. #1
    Join Date
    Jul 2001

    glNewList allocates 260KB!!!!


    I have a big problem in my app.
    Many times I create a displaylist, the following function allocated approx. 260KB!
    I figured this out by checking the memory consumption right before and after the function with GlobalMemoryStatus().
    Important: there is no other function between the GlobalMemoryStatus-call.
    It is only the call to "glNewList".

    This leads to a secure problem: after creation of 1000 displaylists, it can be possible, that 1000x 260KB are allocated.

    Any ideas?
    How can I release the memory?

    (win xp/32)

  2. #2
    Join Date
    Apr 2000
    Belgium (Europe)

    Re: glNewList allocates 260KB!!!!

    You know... if you'd read the documentation of the glNewList function you'd have your answer.

    I don't even know this function and a quick google tells me you need to call glEndList.

  3. #3
    Join Date
    Jul 2001

    Re: glNewList allocates 260KB!!!!


    but the problem is that glEndList do not release the memory.
    If I use 1000x glNewlist and glEndList, there can be 260MB allocated!

  4. #4
    Join Date
    Apr 1999

    Re: glNewList allocates 260KB!!!!

    Quote Originally Posted by Ralf Schneider View Post

    but the problem is that glEndList do not release the memory.
    Where in the documentation does it say glEndList "releases memory"?

    In your original post, you were afraid of many different 260MB being created, and OReubens pointed out that glEndList must be called to replace an existing list. Now that you are calling glEndList, does the issue of creating thousands of different lists been resolved? If it has, then what's the problem?

    If it's still the 260KB, the probable reason is that these functions have nothing to do with how the internal heap manager operates. It is the job of the heap manager to return memory back to the OS -- using functions such as GlobalMemoryStatus or even tools such as Task Manager cannot be used to accurately pinpoint whether you have a memory leak, unless you're directly calling functions such as GlobalAlloc() or HeapAlloc(). Since you're not doing that, then there is no issue.

    The only time GlobalMemoryStatus or even task manager is useful is if your memory usage was steadily increasing, but you're just calling the same functions over and over again that are supposed to create and destroy resources, whatever those resources happen to be. Then that is clear sign of a memory leak. If the memory usage remains stable and you are definitely calling the functions correctly, then there is more than likely no memory leak.

    The heap manager is smart enough to figure out that you may need the memory again, therefore it doesn't return the memory back to the OS immediately -- instead it holds it in reserve for subsequent allocations.


    Paul McKenzie
    Last edited by Paul McKenzie; January 13th, 2013 at 09:39 AM.

Posting Permissions

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

Windows Mobile Development Center

Click Here to Expand Forum to Full Width

On-Demand Webinars (sponsored)