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 9135363
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T08:48:52+00:00 2026-06-17T08:48:52+00:00

False alarm! (read the edit) I’m trying to make a small game, using SDL.

  • 0

False alarm! (read the edit)

I’m trying to make a small game, using SDL. When an entity is created, its image should up the refcount, and that’s no problem. The problem comes when it’s time to use “SDL_FreeSurface(image)” (do decrease it), this should happen within the entity itself so I’m trying to create my own destructor, as a test to see if it got called at all I added a cout, but it’s called every tick for some reason? It’s not deleting anything so I suppose I also have to take care of all the entities values when I do get it to work (thought that I only had to take care of the special cases, such as this).

Entity::~Entity()
{
    cout << "I'm deleted" << endl;
    //SDL_FreeSurface(image);
}

If destructors are supposed to be called all the time (?) why is that?

EDIT
I just realized that during each tick I use some temporary entities, it’s probably those that get deconstructed, sorry feel free to lock this.

  • 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-06-17T08:48:53+00:00Added an answer on June 17, 2026 at 8:48 am

    Your destructor will be called every time an object of class Entity is destroyed and only then.

    If your destructor is called at every tick, that means an object is destroyed at every tick. Likely you’re creating a temporary Entity object at every tick and it gets destroyed right away (for example you might be passing an Entity object by value).

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

Sidebar

Related Questions

I am trying to run alarm which make alert dialog run in home screen
EDIT: False alarm. I was able to resolve the issue. Apparently I was to
In my soundboard app I have created a context menu using this code. public
I'm trying to stop a repeating alarm. I already looked all over the web
Im trying to set an alarm that will send an intent to a broadcast
What I am trying to do is a basic alarm app on Android. When
I need to make a simple alarm clock application that, instead of playing a
Update: False alarm! The source of the error was elsewhere. (See at the end
I'm trying to set up an alarm receiver right after booting. Therefore, i have
I am trying to implement a location alarm kind of application. But whenever my

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.