Archived

This topic is now archived and is closed to further replies.

Windows is changing the swap-file size

This topic is 5671 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Shit... I hope this is not one of those unfindable bugs: After playing about 30 min - 1h30m with my new turn-based drinking game, windows tries to increase the swap file size. As for now the game doesn''t suport Alt+Tab and doesn''t restore surfaces we have to start again because when Windows does that it focuses the desktop. The game has no other bugs, it works perfectly so I suposse that I''m assigning memory that I''m not freeing but can''t find where... The question is: how can I know, while debugging, how many portions of memory (news) are assigned, their size and their type? May it be a problem with the stack or only with data? (I think it cannot be the stack because the program would crash sooner or later). Thanx! Real programers are not afraid from maths! (from an Asfixia Member I think) JJpRiVaTe

Share this post


Link to post
Share on other sites
How much memory is actually being used? What OS are you using? What types of memory are you allocating in-game (video, system)? More information may assist.

I assume you''re using 9x, I would try to find a program similar to WinTop to view how much memory is being used. Also try logging each memory allocation and deallocation, make counters to monitor the amount of memory that is in use at shutdown, etc.



MatrixCubed
http://MatrixCubed.cjb.net

Share this post


Link to post
Share on other sites
quote:
Original post by MatrixCubed
How much memory is actually being used? What OS are you using? What types of memory are you allocating in-game (video, system)? More information may assist.
I assume you're using 9x, I would try to find a program similar to WinTop to view how much memory is being used. Also try logging each memory allocation and deallocation, make counters to monitor the amount of memory that is in use at shutdown, etc.



Ok. It's XP, actually I'm using DirectDraw8 and everything else is memory allocated with new operator and freed with deleted (in theory it is freed O )

I know I can put counters, and I can debug by hand putting sentences of control where I need them but what I ask is if it is possible to view the list of allocated zones of memory, so don't have to do write the debug code.

I assume I'm forgetting to free some memory in some operations, which causes the program to require more and more memory and windows must increase the swap file size.

IDEA: I'm looking the mouse input code now, I think I'm assigning a DIMOUSESTATE in every frame that I don't free, but maybe not.

EDIT: The mouse function was ok but REAL SHIIIT! en each blit operation I was creating a RECT structure that I wasn't deleting :ooooooo I'll accept whatever punish you decide O

By the way, matrixcubed, I far pass 1 Gb per month without receiving anything illegal from the net, and know many people who does too. It's true that only few months.

[edited by - jjmontes on June 2, 2002 3:32:22 PM]

Share this post


Link to post
Share on other sites
If you have MSVC, it comes with extensive debugging support routines. CRT has a debug memory manager that can report memory leaks along with the source file and line where the memory was allocated. Look up _CrtMemCheckpoint and follow the related links. You can, for instance, create a checkpoint in the beginning and in the end of each frame; if the difference between them is not zero, you''re leaking memory. See _CrtMemDumpAllObjectsSince.

Share this post


Link to post
Share on other sites
Every game I have ever played seems to leave stuff in there. If I play one game for a while, it stays at a certain size. As soon as I switch games, it increases. If I switch to a third, it increases again. I think it is a Windows issue.

---
Make it work.
Make it fast.

"Commmmpuuuuterrrr.." --Scotty Star Trek IV:The Voyage Home

Share this post


Link to post
Share on other sites
Thanks you IndirectX for the help.

I usually work with the memory very carefully and follow good-programming practiques but I started this game as a joke and for learning DirectX8 and passed over all the error-checking, memory managment,closing functions.

Share this post


Link to post
Share on other sites
Include this:


  

// enable C RunTime library debug heap allocators

#define _CRTDBG_MAP_ALLOC

#include "crtdbg.h"

#define DEBUG_NEW_FN new( _NORMAL_BLOCK, __FILE__, __LINE__)

#define new DEBUG_NEW_FN




Then, include this at the beggining of your app:


  

// enable C RunTime library leak checking

int nOldState = _CrtSetDbgFlag(_CRTDBG_REPORT_FLAG);
_CrtSetDbgFlag(nOldState | _CRTDBG_LEAK_CHECK_DF);



Execute the program for a couple of minutes, and see how the leaks appears...

Share this post


Link to post
Share on other sites
How do I see it?

How does this works? Where can I see the leaks? Don''t will it report legal memory asignements too? In my debug window doesn''t appear nothing.

Real programers are not afraid from maths! (I am)
(from an Asfixia Member I think)
JJpRiVaTe (Private Zone)

Share this post


Link to post
Share on other sites
Make a new project, add a blank file, type this:


    

// enable C RunTime library debug heap allocators

#define _CRTDBG_MAP_ALLOC

#include "crtdbg.h"

#define DEBUG_NEW_FN new( _NORMAL_BLOCK, __FILE__, __LINE__)

#define new DEBUG_NEW_FN



#define WIN32_LEAN_AND_MEAN

#include <windows.h>


class Foo
{
int Bar;
};


int APIENTRY WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
// enable C RunTime library leak checking

int nOldState = _CrtSetDbgFlag(_CRTDBG_REPORT_FLAG);
_CrtSetDbgFlag(nOldState | _CRTDBG_LEAK_CHECK_DF);


Foo *Pointer;
Pointer = new Foo[100];


return 0;
}



If you compile and execute in debug modes, this is the output in the debug window under VC++ 6.0 SP5:



Loaded 'C:\WINDOWS\system32\kernel32.dll', no matching symbolic information found.
Detected memory leaks!
Dumping objects ->
d:\mis documentos\proyectos\dummy\dummy.cpp(29) : {40} normal block at 0x003707B8, 400 bytes long.
Data: < > CD CD CD CD CD CD CD CD CD CD CD CD CD CD CD CD
Object dump complete.
The thread 0x7E4 has exited with code 0 (0x0).
The program 'D:\Mis documentos\Proyectos\dummy\Debug\dummy.exe' has exited with code 0 (0x0).




[edited by - Neodraco on June 4, 2002 7:45:05 PM]

Share this post


Link to post
Share on other sites