我正在编写一个程序来更好地理解ncurses,当我通过valgrind推动它时,它会输出许多与ncurses命令相关的泄漏信息。但是,我只使用stdscr,并在main()的末尾调用endwin()。我通过使用menu.h设置了用户选项,最后使用了free_item和free_menu:
menuChoice(WINDOW* scr, std::vector<std::string> *choices,
std::string desc)
{
//create the menu and the item pointer vector
MENU* my_men
复制:
比方说:
int main()
{
char* test = new char[50000];
return 0;
}
程序完成后分配的内存发生了什么变化?它会立即为其他应用程序释放吗?或者过了一段时间?或者是它永远输给了系统?还是它被交换到磁盘上,不再返回RAM?或者是完全不同的东西?
我想知道在主要的3操作系统上会发生什么: Windows (XP和XP,如果有什么不同),Linux,Mac。
我正在为TCP连接编写客户端,从IP到socket_addr的转换会造成内存泄漏。
有以下过程:
#include <netdb.h>
#include <sys/socket.h>
#include <sys/types.h>
/** there is some code like method header etc. */
hostent * host = gethostbyaddr( ip, 4, AF_INET ); // ip is char[4], I use IPv4
if ( !host ) return -2; // bad IP