I'm making a rogue-like game using PDCurses and it works great. However, using _CrtDumpMemoryLeaks() to find memory leaks at the end of my program shows that what looks like the PDCurses screen buffer hasn't been freed. I am ending PDCurses with endwin() and deleting subwindows etc. but nothing seems to help.
Is there some way to fix this or is it something I just shouldn't worry about?
You can use delscreen(). (Specifically, for PDCurses, "delscreen(SP)".) However, it's also something that you shouldn't worry about. All memory allocated by a process is freed when the process ends. So you should only concern yourself with this if you're doing a lot of stuff in the program after the curses portion ends. (Even then, we're talking about a very small amount of memory.)
endwin() doesn't free the memory because it has to allow for a temporary exit and return. (Hence why delscreen() was created.) But it's still very important to call endwin() on your way out, to ensure that the terminal is restored to the correct state. (This doesn't always apply with PDCurses, but it's a good habit to get in anyway, for the sake of portability.)
Thanks for your help, this clears things up for me.
Log in to post a comment.