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

  • SEARCH
  • Home
  • 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 7668027
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T15:15:12+00:00 2026-05-31T15:15:12+00:00

My program renders large jpegs as textures one at a time and allows the

  • 0

My program renders large jpegs as textures one at a time and allows the user to switch between them by re-using the “same” texture.

I call glGenTextures(1, &texture); once at the start.

Then each time I want to swap the image I use:

FreeTexture( texture );
ROI_img = fetch_image(temp, sortVector[tPiece]);

loadTexture_Ipl( ROI_img , &texture );

here are the two functions being called:

int loadTexture_Ipl(IplImage *image, GLuint *text)
{
    if (image==NULL) return -1;
    glBindTexture( GL_TEXTURE_2D, *text );

    glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
    glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
    glPixelStorei(GL_UNPACK_ALIGNMENT, 4);

    glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, ROI_WIDTH, ROI_HEIGHT,0, GL_BGR, GL_UNSIGNED_BYTE, image->imageData);
    return 0;
}

void FreeTexture(GLuint texture)
{
    glDeleteTextures( 1, &texture);
}

My problem is that after a couple of images they stop rendering (texture is all black). If I keep trying to switch I get this error message:

test(55248,0xacdf22c0) malloc: *** mmap(size=744001536) failed (error code=12)
*** error: can't allocate region
*** set a breakpoint in malloc_error_break to debug
Mar 19 11:57:51 Ants-MacBook-Pro.local test[55248] <Error>: CGSImageDataLock: Cannot allocate memory

I thought that glDeleteTextures would free the memory each time??

Any ideas on how to better implement this?

p.s. here is a screen of the memory leaks being encountered (https://p.twimg.com/AoWVy8FCMAEK8q7.png:large)

  • 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-31T15:15:13+00:00Added an answer on May 31, 2026 at 3:15 pm

    Since you want to reuse your texture, you shouldn’t delete it with glDeleteTextures. If you do that, you need to create a new texture using glGenTextures, and I don’t see you are doing it in the loadTexture_Ipl function.

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

Sidebar

Related Questions

I'm working on a program that uses HTML/CSS/Javascript/JQuery for its user interface. One of
We know that using string concatenation to form SQL queries renders a program vulnerable
I have a test program that programmatically renders a texture and then renders a
I've got a Python program using PIL to render text, and it works great
I'm working a program which renders a dynamic high resolution voxel landscape. Currently I
I'm working on a program that renders iterated fractal systems. I wanted to add
I'm trying to use a texture atlas in a game program I'm writing in
I've created an applet which has one large panel to display data surrounded by
I'm writing a program which calculates the Mandelbrot Set (and then renders it in
I'm currently creating an SDL/OpenGL program, which renders objects based on a few state

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.