Anyone got any ideas where 4k a sec is coming from?

Started by
40 comments, last by Brain 8 years, 10 months ago

Task Manager is not a profiler or memory analizer. The numbers you see in there mean different things and can change when the Windows OS is moving pages, without a cause in your program.

Advertisement

Even when it's sat dormant doing nothing?

not loading anything and no input from keyboard mouse or anything:

At start of timer:

4792k

after five mins of inactivity:

4832k

Initializing media by loading one image into a class, but not activating any objects using new.

At start:

6920k

after five mins of inactivity:

175,036k

That's more than a 2 hour soundtrack movie on youtube!!!

If you get near a point, make it!

If you're worried about leakage then download vld and test the program. Task manager is NOT an appropriate tool for measuring memory usage.

void hurrrrrrrr() {__asm sub [ebp+4],5;}

There are ten kinds of people in this world: those who understand binary and those who don't.

On a slightly related note, have i mentioned that the singleton pattern makes god kill kittens? :)

It sounds to me like you have a memory leak somewhere, but without properly testing it in a proper debugger/profiler you can't be sure. You might want to check it in a leak checking profiler like valgrind for windows which will track leaks at the system level, without you having to change or rebuild your code.

I used this utility on linux for many years with big C++ programs and i swear by it. Haven't tested this windows version though, so your mileage may vary.

Nice one,

I will research singleton applications and their inherent evil nature, and look into vld.

Help is much appreciated as always :D

If you get near a point, make it!

have you tried commenting our various function calls? to be honest I am very suspect of your LoadMedia stuff. It could be something your code is using, not necessarily just your code, that is causing the leak.

This may or may not be related but, I spotted this leak:

        bool fLoadMedia()
        {
            WindowSize.w = SDL_GetWindowSurface(Window)->w;
            WindowSize.h = SDL_GetWindowSurface(Window)->h;
            SDL_Rect screenCoords= {0, 0, WindowSize.w, WindowSize.h};
 
            if(bLoadMedia)
            {
                mediaAssets= new LoadMedia(Renderer, MainTTfont, screenCoords);
                if(mediaAssets->fInitializeMedia())
            }
            return true;
        }

Then in the cleanUp function...

        void OnCleanup()
        {
            if(bLoadMedia)
                mediaAssets->fCleanupAssets();
...

You are not deleting the allocated memory pointed at by mediaAssets, unless you are calling `delete this;` in fCleanupAssets(); It should be


if(bLoadMedia)
{ 
     mediaAssets->fCleanupAssets();
     delete mediaAssets;
}

Okay new problem, probably related tbh.

When a linked list has the following:

class MyObject
{
    int count;
    int iCurrentThingy;
 
public:
    MyObject()
    {
        dMSG("MyObject constructor called");
    }
 
    MyObject(int i) : iCurrentThingy(i)
    {
        dMSG("MyObject overloaded constructor called");
    }
 
    ~MyObject()
    {
        dMSG("MyObject destructor called");
    }
 
    int fReturnThingy()
    {
        return iCurrentThingy;
    }
};
 
LinkedList<MyObject> EntityList;

And I call the following on adding to said list

void fInsertAtHead(ListItem* listItem)
    {
        Node* pTemp= new Node;
        pTemp->current= listItem;
        pTemp->next= head;
        head= pTemp;
        count++;
    }
If you get near a point, make it!

Then call this to clear the list:

void fClearAll()
    {
        while(head!=NULL)
        {
            Node* pTBDel= head;
            delete pTBDel->current;
            head= head->next;
            count--;
        }
    }
If you get near a point, make it!

Is there a question you have? You should be asking yourself "why aren't I using the standard library linked list which doesn't have any bugs in it?" If you really want to make your own linked list we can't stop you of course, but you seem to be making your life harder than it has to be.

C++: A Dialog | C++0x Features: Part1 (lambdas, auto, static_assert) , Part 2 (rvalue references) , Part 3 (decltype) | Write Games | Fix Your Timestep!

This topic is closed to new replies.

Advertisement