나는 gtkmm을 배우려고하는데, 데비안에서 3.0을 사용하는 것이 꽤 힘들어서 gtkmm 2.4를 사용하기로 결정했습니다. 어쨌든, 제가 시도하고있는 예제는 여기에 있습니다 : http://developer.gnome.org/gtkmm-tutorial/2.24/sec-helloworld.html.en. 그것은 잘 컴파일이 괜찮아 aswell를 실행,하지만 난 닫을 때 그것은 Valgrind의, (한 번 버튼을 클릭 한 후)이의 라인을 따라 뭔가 누수를 많이보고 : 내가 프로그램을 중지하면gtkmm/C++ 첫 번째 안녕하세요 세계 누수 메모리
==4254== Memcheck, a memory error detector
==4254== Copyright (C) 2002-2010, and GNU GPL'd, by Julian Seward et al.
==4254== Using Valgrind-3.6.0.SVN-Debian and LibVEX; rerun with -h for copyright info
==4254== Command: ./bin/jmb
==4254==
Hello World
==4254==
==4254== HEAP SUMMARY:
==4254== in use at exit: 942,940 bytes in 7,968 blocks
==4254== total heap usage: 14,191 allocs, 6,223 frees, 3,272,961 bytes allocated
==4254==
==4254== LEAK SUMMARY:
==4254== definitely lost: 2,620 bytes in 6 blocks
==4254== indirectly lost: 5,936 bytes in 187 blocks
==4254== possibly lost: 358,625 bytes in 1,775 blocks
==4254== still reachable: 575,759 bytes in 6,000 blocks
==4254== suppressed: 0 bytes in 0 blocks
==4254== Rerun with --leak-check=full to see details of leaked memory
==4254==
==4254== For counts of detected and suppressed errors, rerun with: -v
==4254== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 9 from 9)
이 발생을 참조 또는 창 닫기 버튼을 클릭하십시오 (이 경우 Shift-Meta-C를 사용하여 창 관리자 때문에 창을 닫아야합니다). 이것은 마지막 포인터 하나를 지울 수없는 MySQL 커넥터와 같은 예상 된 동작입니까? 이 경우 많은 양의 메모리가 "허용"되지 않은 것처럼 보입니다. 아니면 나는 정말 간단한 것을 놓치고 있습니까? 그것의 위해서
여기 내 코드입니다 : (테스트로 변경하여 HelloWorld) MAIN.CPP :#include "gui/Test.hpp"
#include <gtkmm/main.h>
int main(int argc, char **argv)
{
Gtk::Main kit(argc, argv);
Test t;
Gtk::Main::run(t);
return 0;
}
Test.hpp :
#pragma once
#include <gtkmm/button.h>
#include <gtkmm/window.h>
class Test
: public Gtk::Window
{
public:
Test();
virtual ~Test();
protected:
//Signal handlers:
void on_button_clicked();
//Member widgets:
Gtk::Button m_button;
};
Test.cpp에 :
#include "Test.hpp"
#include <iostream>
Test::Test()
: m_button("Hello World") // creates a new button with label "Hello World".
{
// Sets the border width of the window.
set_border_width(10);
// When the button receives the "clicked" signal, it will call the
// on_button_clicked() method defined below.
m_button.signal_clicked().connect(sigc::mem_fun(*this,
&Test::on_button_clicked));
// This packs the button into the Window (a container).
add(m_button);
// The final step is to display this newly created widget...
m_button.show();
}
Test::~Test()
{
}
void Test::on_button_clicked()
{
std::cout << "Hello World" << std::endl;
}
미리 감사드립니다.
gtk 질문에 대한 적절한 답변이 아니지만 일반적으로 메모리 누수를 조사 할 때 자세한 내용을 확인하려면 'valgrind --leak-check = full --leak-resolution = high --track-origins = yes'을 사용하십시오. –
그 정보를 처리 할 수있는 정보가 너무 많습니다. 출력에 링크를 추가해야합니까? – lfxgroove
신중히 검토하고 이해하면 나중에 유용 할 유용한 운동이 될 것입니다. 다른 사람이 당신을 위해 그것을 해석 할 수 있지만 그렇게 할 수 있다면 당신도 할 수 있습니다. 출력을 줄이기 위해'--leak-resolution = high'를 제거하면 도움이 될 것입니다. –