Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6320419
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T15:58:09+00:00 2026-05-24T15:58:09+00:00

So I wanted to see what would happen to a basic Qt4 Application compiled

  • 0

So I wanted to see what would happen to a basic Qt4 Application compiled from a simple Makefile when run through Valgrind. What would be causing these leaks? I am deleting any dynamically allocated objects on my end. Also when exiting the program I only click on the close (X) up in the upper right corner. Do GUI libs just not “free()” any of the memory they malloc()’d?

The Makefile reduced from qmake command is:

####### Compiler, tools and options

CXX           = g++
CXXFLAGS      = -pipe -O2 -Wall -W
LIBS_INCLUDE  = ${HOME}
INCPATH       = -I$(LIBS_INCLUDE)/QtSDK/Desktop/Qt/473/gcc/mkspecs/default \
                -I. \
                -I$(LIBS_INCLUDE)/QtSDK/Desktop/Qt/473/gcc/include/QtCore \
                -I$(LIBS_INCLUDE)/QtSDK/Desktop/Qt/473/gcc/include/QtGui \
                -I$(LIBS_INCLUDE)/QtSDK/Desktop/Qt/473/gcc/include 
LINK          = g++
LFLAGS        = -Wl,-O1 -Wl,-rpath,$(LIBS_INCLUDE)/QtSDK/Desktop/Qt/473/gcc/lib
LIBS          = $(SUBLIBS)  -L$(LIBS_INCLUDE)/QtSDK/Desktop/Qt/473/gcc/lib -lQtGui -lQtCore -lpthread
QMAKE         = $(LIBS_INCLUDE)/QtSDK/Desktop/Qt/473/gcc/bin/qmake
OBJECTS_DIR   = ./
SOURCES       = main.cpp
OBJECTS       = main.o
QMAKE_TARGET  = Main
TARGET        = Main

####### Build rules
first: all

all: $(TARGET)

$(TARGET):  $(OBJECTS)
        $(LINK) $(LFLAGS) -o $(TARGET) $(OBJECTS) $(OBJCOMP) $(LIBS)

####### Compile

main.o: main.cpp
        $(CXX) -c $(CXXFLAGS) $(INCPATH) -o main.o main.cpp

The only source code is:

int main(int argc, char *argv[])
{
    QApplication app(argc, argv);
    QWidget window;
    window.resize( 320,240 );
    window.setWindowTitle( 
        QApplication::translate( "toplevel", "Top-level Widget" ) );
    window.show( );

    QPushButton *button = new QPushButton(
        QApplication::translate( "childwidget", "Press me"), &window );
    button->move( 100, 100 );
    button->show( );
    delete button;
    return app.exec();
}

When run through valgrind I get the following (Removed Large Portion In Middle):

==3836== Memcheck, a memory error detector
==3836== Copyright (C) 2002-2009, and GNU GPL'd, by Julian Seward et al.
==3836== Using Valgrind-3.5.0 and LibVEX; rerun with -h for copyright info
==3836== Command: ./Main
==3836== 
Xlib:  extension "RANDR" missing on display ":0.0".
==3836== 
==3836== HEAP SUMMARY:
==3836==     in use at exit: 924,383 bytes in 8,679 blocks
==3836==   total heap usage: 37,234 allocs, 28,555 frees, 4,314,180 bytes allocated
==3836== 
==3836== 1 bytes in 1 blocks are possibly lost in loss record 1 of 4,534
==3836==    at 0x400677E: malloc (vg_replace_malloc.c:195)
==3836==    by 0xA1DFA4: g_malloc (in /lib/libglib-2.0.so.0.2600.0)
==3836==    by 0xA37F29: g_strdup (in /lib/libglib-2.0.so.0.2600.0)
==3836==    by 0xB2A6FA: g_param_spec_string (in /lib/libgobject-2.0.so.0.2600.0)
==3836==    by 0x41F36473: ??? (in /usr/lib/libgtk-x11-2.0.so.0.2200.0)
==3836==    by 0xB3D237: g_type_class_ref (in /lib/libgobject-2.0.so.0.2600.0)
==3836==    by 0xB20B38: g_object_newv (in /lib/libgobject-2.0.so.0.2600.0)
==3836==    by 0xB212EF: g_object_new (in /lib/libgobject-2.0.so.0.2600.0)
==3836==    by 0x41F34857: gtk_settings_get_for_screen (in /usr/lib/libgtk-x11-2.0.so.0.2200.0)
==3836==    by 0x41ED0CB6: ??? (in /usr/lib/libgtk-x11-2.0.so.0.2200.0)
==3836==    by 0xB377C7: g_cclosure_marshal_VOID__OBJECT (in /lib/libgobject-2.0.so.0.2600.0)
==3836==    by 0xB1ABE2: g_closure_invoke (in /lib/libgobject-2.0.so.0.2600.0)
==3836== 
...
==3836== 
==3836== 23,048 bytes in 1 blocks are possibly lost in loss record 4,531 of 4,534
==3836==    at 0x400677E: malloc (vg_replace_malloc.c:195)
==3836==    by 0x16F42D: ??? (in /usr/lib/libfreetype.so.6.6.0)
==3836==    by 0x17400B: ft_mem_qalloc (in /usr/lib/libfreetype.so.6.6.0)
==3836==    by 0x174063: ft_mem_alloc (in /usr/lib/libfreetype.so.6.6.0)
==3836==    by 0x174508: ft_mem_qrealloc (in /usr/lib/libfreetype.so.6.6.0)
==3836==    by 0x17457F: ft_mem_realloc (in /usr/lib/libfreetype.so.6.6.0)
==3836==    by 0x1A2E52: ??? (in /usr/lib/libfreetype.so.6.6.0)
==3836==    by 0x1A709B: ??? (in /usr/lib/libfreetype.so.6.6.0)
==3836==    by 0x180338: ??? (in /usr/lib/libfreetype.so.6.6.0)
==3836==    by 0x175B5D: ??? (in /usr/lib/libfreetype.so.6.6.0)
==3836==    by 0x1780B0: FT_Open_Face (in /usr/lib/libfreetype.so.6.6.0)
==3836==    by 0x1791FF: FT_New_Face (in /usr/lib/libfreetype.so.6.6.0)
==3836== 
==3836== 53,244 bytes in 29 blocks are possibly lost in loss record 4,534 of 4,534
==3836==    at 0x400677E: malloc (vg_replace_malloc.c:195)
==3836==    by 0xA1DFA4: g_malloc (in /lib/libglib-2.0.so.0.2600.0)
==3836==    by 0xA36050: g_slice_alloc (in /lib/libglib-2.0.so.0.2600.0)
==3836==    by 0xA36315: g_slice_alloc0 (in /lib/libglib-2.0.so.0.2600.0)
==3836==    by 0xB40077: g_type_create_instance (in /lib/libgobject-2.0.so.0.2600.0)
==3836==    by 0xB1CE35: ??? (in /lib/libgobject-2.0.so.0.2600.0)
==3836==    by 0xB205C6: g_object_newv (in /lib/libgobject-2.0.so.0.2600.0)
==3836==    by 0xB212EF: g_object_new (in /lib/libgobject-2.0.so.0.2600.0)
==3836==    by 0x54B8FA3: ??? (in /usr/lib/gtk-2.0/2.10.0/engines/libclearlooks.so)
==3836==    by 0x41F0CDDD: ??? (in /usr/lib/libgtk-x11-2.0.so.0.2200.0)
==3836==    by 0x41F11C24: gtk_rc_get_style (in /usr/lib/libgtk-x11-2.0.so.0.2200.0)
==3836==    by 0x4200A81F: ??? (in /usr/lib/libgtk-x11-2.0.so.0.2200.0)
==3836== 
==3836== LEAK SUMMARY:
==3836==    definitely lost: 1,912 bytes in 7 blocks
==3836==    indirectly lost: 5,060 bytes in 250 blocks
==3836==      possibly lost: 491,358 bytes in 2,893 blocks
==3836==    still reachable: 426,053 bytes in 5,529 blocks
==3836==         suppressed: 0 bytes in 0 blocks
==3836== Reachable blocks (those to which a pointer was found) are not shown.
==3836== To see them, rerun with: --leak-check=full --show-reachable=yes
==3836== 
==3836== For counts of detected and suppressed errors, rerun with: -v
==3836== ERROR SUMMARY: 1336 errors from 1336 contexts (suppressed: 114 from 11)
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T15:58:10+00:00Added an answer on May 24, 2026 at 3:58 pm

    I compiled your short application and (using the visual studio crt memoryleak detector) could not find any memory leaks. So whatever valgrind reports is not directly related to your code.

    However, you are deleting the QPushButton before the application is actually running. Usually ownership of QWindows is transfered to the parent window, so you don’t need to cleanup the objects by yourself, the parent window handles that for you (if this is not the case, it’s stated in the documentation).

    So, to correct your code, just delete the delete.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I been playing around with my code and I wanted to see what would
I wanted to see what some suggested approaches would be to validate a field
Im making an application in cocoa and wanted to see if some strings in
I wanted to see if folks were using decimal for financial applications instead of
I wanted to see what folks thought were the best way to help junior
I wanted to see what happened if you change the reference of an object
I wanted to see if there is a cleaner and more effective way of
I just wanted to see if I could have your thoughts on the design
I just wanted to see if anyone is aware of any other debuggers capable
I see there is full ajax mode but I wanted to see if there

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.