Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6892223
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T06:30:29+00:00 2026-05-27T06:30:29+00:00

I started creating a small game engine for an independent project. When writing the

  • 0

I started creating a small game engine for an independent project. When writing the graphics portion of the engine, I noticed there was a memory leak that dissapears when I stop using glClearColor and the glPushMatrix/glPopMatrix pairs.
From what I’ve researched it appears to be a common occurrence, but I haven’t found an answer as to why this occurs.

The bizarre thing is, the leak goes on for a minute or two, and then just stops (very consistently).
Using the task manager, it shows 11,012K when the leak stops.

Additional Notes: I am not using GLUT, but I am using GLEW_1.7 for mapped vbo’s.

Any ideas what could be causing this?
Is is just a non-issue because of something odd that OpenGL does under the hood?

These are the only place I’m calling glClearColor, glPushMatrix, and glPopMatrix.

void GraphicsDevice::updateCameraAndClear(IWindow* window)
{
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    gluPerspective(32, window->getAspectRatio(), 0.0, 100.0);

    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();

    glClearColor(100.0f / 255, 149.0f / 255, 237.0f / 255, 1.0f);
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

    glEnable(GL_CULL_FACE); // Enable Culling
    glCullFace(GL_BACK);
    glEnable(GL_NORMALIZE);
    glEnable(GL_POLYGON_SMOOTH);
}

void Engine::draw(void)
{
    GraphicsDevice::Instance()->updateCameraAndClear(_window);
    if ( !_states.empty() )
    {
        for(std::vector<IState*>::iterator i = _states.begin(); i != _states.end(); i++)
        {
            glPushMatrix();
            (*i)->draw(this);
            glPopMatrix();
        }
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T06:30:30+00:00Added an answer on May 27, 2026 at 6:30 am

    Perhaps you use the Push/Pop pair wrongly, pushing one extra time more than required. But eventually that would lead to buffer overflow..

    Check your Push/Pop pairs and make sure thay are pairs indeed. The leak could be in surrounding code as well.

    EDIT: OpenGL receives instructions, but they are not executed immediately. OpenGL has a plan of its own. If you glDeleteTextures you are not guaranteed the texture will be removed until glFinish/glFlush command (or even after?). Maybe there’s something else accumulating in your Draw code that OpenGL keeps in memory. Which gives described effect when co-joined with glPush/glPop pairs.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have started creating a game, and I added a second project, it's the
I have finally started messing around with creating some apps that work with RESTful
I've started development on a project (which used CVS) by downloading its sources, creating
I am trying to learn symfony framework by creating a small project. Since I
When importing a project into eclipse, it somehow started creating recursive versions of the
I have started creating small applications in Java using Net-beans, i was trying to
I'd like to write a small script that implements RFC4709 for OS/X. I started
I just started creating my data-access layer using LinqToSql. Everybody is talking about the
I am just getting started creating an AJAX application using server side push. I
I have recently started creating an iPhone application using Appcelerator's Titanium. Since the application

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.