#274 Memory Leak?

Latest Subversion
open
Client (126)
3
2009-01-08
2006-12-09
No

By watching the Windows XP Task Manager's "Mem Usage" statistic, a possible memory leak in FO's client becomes apparent. I'm not sure how accurate this is, or (see below) how it's dealing with disk caching, but regardless, there seems to be a steady increase in memory usage while just looking at the galaxy map, doing nothing else.

On the main splash screen, doing nothing, Mem Usage is stable at 37484 K. In this test, music is off and sound is on, though sounds being heard (due to button rollovers) seem to have no effect on Mem Usage.

Single player game started - sit looking at map. Starting around 40000 K, increasing ~100 K / s

Time - Mem Usage

4:55 - 50000 K
4:58 - 60000 K
5:04 - 85000 K
5:08 - 100000 K

Then, I minimized the FO window, and Mem Usage dropped to 3452 K, then immediately started growing again ~100 KB / s (while still minimized). Since (after restoring later) FO doesn't seem to have to reload all art, I assume some odd caching is going on here. For the purposes of this bug, I assume this doesn't matter.

Restoring the FO window causes no significant change that can be readily distinguished from the 100 K / s growth, compared to what it was immediately before restoring (ie. growth over time above 3400 K )

Reminimizing returns Mem Usage to ~3400 K

Discussion

  • Nobody/Anonymous

    Logged In: NO

    I also tried RC5 and everything is laggy in Windows. Is it written in .NET or C++?

     
  • Geoff Topping

    Geoff Topping - 2006-12-19

    Logged In: YES
    user_id=913462
    Originator: YES

    C++, though there's been some difficulty getting it to compile on Windows without MSVC adding unnecessary .NET requirements to run the binary.

    If you're getting poor performance, that's not necessarily related to a potential memory leak. Please submit a more detailed bug report outlining when and on what screens and in what way "everything is laggy".

     
  • Martin Doucha

    Martin Doucha - 2007-07-17

    Logged In: YES
    user_id=1846482
    Originator: NO

    I've just run freeorion in valgrind and it spewed out 500kB log of memory usage errors. Here's leak summary:

    ==7245== LEAK SUMMARY:
    ==7245== definitely lost: 48,101 bytes in 1,892 blocks.
    ==7245== indirectly lost: 51,361 bytes in 2,888 blocks.
    ==7245== possibly lost: 135,019 bytes in 2,084 blocks.
    ==7245== still reachable: 3,883,363 bytes in 6,915 blocks.
    ==7245== suppressed: 0 bytes in 0 blocks.

    All I did was running the program and when main menu came up, I clicked Exit. It's enough to alloc 4MB of memory which never gets freed.

    Some of those memory usage errors are off-by-one read errors in libILU and some memory leaks are in other system libraries though.

     
  • Zach Laine

    Zach Laine - 2007-07-20

    Logged In: YES
    user_id=729903
    Originator: NO

    I've done quite a bit of leak analysis today using Valgrind. It revealed that we have a large amount of leakage due to a few large but fixed-size items that are built only once at startup. This is the bulk of next_ghost's leak report. There were a number of smaller but more frequent leaks that have been fixed. They were happening in places that may actually account for the large leaks over time on Win32.

     
  • Nobody/Anonymous

    Logged In: NO

    Perhaps related, the CPU usage goes up quickly with FO 0.3.1 rc6, and stays high (laptop) sucking down the battery pretty quickly. 70-99% CPU time, i'd say. Desn't seem right for a relatively simple turn-based game with few animations and effects.
    - Ghent

     
  • Nobody/Anonymous

    Logged In: NO

    static / linux also has serious leaking issues. Saving, re-crashing, loading recreates working state but not memory consumption.

     
  • Markus Sinner

    Markus Sinner - 2008-05-23

    Logged In: YES
    user_id=853243
    Originator: NO

    I run valgrind on the statically linked version. There are, indeed, many leaks.

    Unfortunately the game runs veeeeery slow using valgrind, so that it is almost impossible to analyze it confortable. This work has to be done from someone having a heavy-power-machine :-)

    One thing to mention: the freeoriond seems to be "better", it does not alloc very much memory.

    ==26686==
    ==26686== ERROR SUMMARY: 15562 errors from 36 contexts (suppressed: 41 from 1)
    ==26686== malloc/free: in use at exit: 5,477,324 bytes in 16,609 blocks.
    ==26686== malloc/free: 896,730 allocs, 880,121 frees, 381,360,460 bytes allocated.
    ==26686== For counts of detected errors, rerun with: -v
    ==26686== searching for pointers to 16,609 not-freed blocks.
    ==26686== checked 25,208,944 bytes.
    ==26686==
    ==26686== LEAK SUMMARY:
    ==26686== definitely lost: 401,787 bytes in 11,967 blocks.
    ==26686== possibly lost: 147,431 bytes in 767 blocks.
    ==26686== still reachable: 4,928,106 bytes in 3,875 blocks.
    ==26686== suppressed: 0 bytes in 0 blocks.
    ==26686== Use --leak-check=full to see details of leaked memory.

     
  • Ondrej Riha

    Ondrej Riha - 2009-01-05

    From source analysis with cppcheck:

    [FreeOrion/UI/BuildDesignatorWnd.cpp]: Memory leak: BuildDesignatorWnd::m_build_detail_panel
    [FreeOrion/UI/BuildDesignatorWnd.cpp]: Memory leak: BuildDesignatorWnd::m_build_selector
    [FreeOrion/UI/BuildDesignatorWnd.cpp]: Memory leak: BuildDesignatorWnd::m_side_panel
    [FreeOrion/UI/CUIWnd.cpp]: Memory leak: CUIWnd::m_close_button
    [FreeOrion/UI/CUIWnd.cpp]: Memory leak: CUIWnd::m_minimize_button
    [FreeOrion/UI/CUIWnd.cpp]: Memory leak: CUIEditWnd::m_edit
    [FreeOrion/UI/CUIWnd.cpp]: Memory leak: CUIEditWnd::m_ok_bn
    [FreeOrion/UI/CUIWnd.cpp]: Memory leak: CUIEditWnd::m_cancel_bn
    [FreeOrion/UI/CombatWnd.cpp]: Memory leak: CombatWnd::m_combats_lb
    [FreeOrion/UI/DesignWnd.cpp:1981]: Memory leak: design
    [FreeOrion/UI/DesignWnd.cpp]: Memory leak: DesignWnd::m_detail_panel
    [FreeOrion/UI/DesignWnd.cpp]: Memory leak: DesignWnd::m_base_selector
    [FreeOrion/UI/DesignWnd.cpp]: Memory leak: DesignWnd::m_part_palette
    [FreeOrion/UI/DesignWnd.cpp]: Memory leak: DesignWnd::m_main_panel
    [FreeOrion/UI/FleetWnd.cpp]: Memory leak: FleetWnd::m_fleets_lb
    [FreeOrion/UI/FleetWnd.cpp]: Memory leak: FleetWnd::m_new_fleet_drop_target
    [FreeOrion/UI/FleetWnd.cpp]: Memory leak: FleetWnd::m_fleet_detail_panel
    [FreeOrion/UI/FleetWnd.cpp]: Memory leak: FleetDetailWnd::m_fleet_panel
    [FreeOrion/UI/FleetWnd.cpp]: Memory leak: FleetDataPanel::m_num_ships_stat
    [FreeOrion/UI/FleetWnd.cpp]: Memory leak: FleetDataPanel::m_fleet_strength_stat
    [FreeOrion/UI/FleetWnd.cpp]: Memory leak: FleetDataPanel::m_fuel_stat
    [FreeOrion/UI/FleetWnd.cpp]: Memory leak: FleetDetailPanel::m_ships_lb
    [FreeOrion/UI/GalaxySetupWnd.cpp]: Memory leak: GalaxySetupPanel::m_galaxy_shapes_list
    [FreeOrion/UI/GalaxySetupWnd.cpp]: Memory leak: GalaxySetupPanel::m_galaxy_ages_list
    [FreeOrion/UI/GalaxySetupWnd.cpp]: Memory leak: GalaxySetupPanel::m_starlane_freq_list
    [FreeOrion/UI/GalaxySetupWnd.cpp]: Memory leak: GalaxySetupPanel::m_planet_density_list
    [FreeOrion/UI/GalaxySetupWnd.cpp]: Memory leak: GalaxySetupPanel::m_specials_freq_list
    [FreeOrion/UI/GalaxySetupWnd.cpp]: Memory leak: GalaxySetupWnd::m_galaxy_setup_panel
    [FreeOrion/UI/GalaxySetupWnd.cpp]: Memory leak: GalaxySetupWnd::m_empire_name_edit
    [FreeOrion/UI/GalaxySetupWnd.cpp]: Memory leak: GalaxySetupWnd::m_empire_color_selector
    [FreeOrion/UI/GalaxySetupWnd.cpp]: Memory leak: GalaxySetupWnd::m_ok
    [FreeOrion/UI/GalaxySetupWnd.cpp]: Memory leak: GalaxySetupWnd::m_cancel
    [FreeOrion/UI/InGameMenu.cpp]: Memory leak: InGameMenu::m_save_btn
    [FreeOrion/UI/InGameMenu.cpp]: Memory leak: InGameMenu::m_load_btn
    [FreeOrion/UI/InGameMenu.cpp]: Memory leak: InGameMenu::m_options_btn
    [FreeOrion/UI/InGameMenu.cpp]: Memory leak: InGameMenu::m_done_btn
    [FreeOrion/UI/InGameMenu.cpp]: Memory leak: InGameMenu::m_exit_btn
    [FreeOrion/UI/InfoPanels.cpp]: Memory leak: BuildingIndicator::m_progress_bar
    [FreeOrion/UI/IntroScreen.cpp]: Memory leak: IntroScreen::m_single_player
    [FreeOrion/UI/IntroScreen.cpp]: Memory leak: IntroScreen::m_multi_player
    [FreeOrion/UI/IntroScreen.cpp]: Memory leak: IntroScreen::m_load_game
    [FreeOrion/UI/IntroScreen.cpp]: Memory leak: IntroScreen::m_options
    [FreeOrion/UI/IntroScreen.cpp]: Memory leak: IntroScreen::m_about
    [FreeOrion/UI/IntroScreen.cpp]: Memory leak: IntroScreen::m_credits
    [FreeOrion/UI/IntroScreen.cpp]: Memory leak: IntroScreen::m_exit_game
    [FreeOrion/UI/MapWnd.cpp]: Memory leak: MapWnd::m_side_panel
    [FreeOrion/UI/MapWnd.cpp]: Memory leak: MapWnd::m_sitrep_panel
    [FreeOrion/UI/MapWnd.cpp]: Memory leak: MapWnd::m_chat_edit
    [FreeOrion/UI/MapWnd.cpp]: Memory leak: MapWnd::m_turn_update
    [FreeOrion/UI/MapWnd.cpp]: Memory leak: MapWnd::m_food
    [FreeOrion/UI/MapWnd.cpp]: Memory leak: MapWnd::m_mineral
    [FreeOrion/UI/MapWnd.cpp]: Memory leak: MapWnd::m_trade
    [FreeOrion/UI/MapWnd.cpp]: Memory leak: MapWnd::m_population
    [FreeOrion/UI/MapWnd.cpp]: Memory leak: MapWnd::m_research
    [FreeOrion/UI/MapWnd.cpp]: Memory leak: MapWnd::m_industry
    [FreeOrion/UI/MapWnd.cpp]: Memory leak: MapWnd::m_btn_siterep
    [FreeOrion/UI/MapWnd.cpp]: Memory leak: MapWnd::m_btn_research
    [FreeOrion/UI/MapWnd.cpp]: Memory leak: MapWnd::m_btn_production
    [FreeOrion/UI/MapWnd.cpp]: Memory leak: MapWnd::m_btn_design
    [FreeOrion/UI/MapWnd.cpp]: Memory leak: MapWnd::m_btn_menu
    [FreeOrion/UI/MapWnd.cpp]: Memory leak: MapWnd::m_FPS
    [FreeOrion/UI/MapWnd.cpp]: Memory leak: MapWnd::m_side_panel
    [FreeOrion/UI/MapWnd.cpp]: Memory leak: MapWnd::m_sitrep_panel
    [FreeOrion/UI/MapWnd.cpp]: Memory leak: MapWnd::m_chat_edit
    [FreeOrion/UI/MapWnd.cpp]: Memory leak: MapWnd::m_turn_update
    [FreeOrion/UI/MapWnd.cpp]: Memory leak: MapWnd::m_food
    [FreeOrion/UI/MapWnd.cpp]: Memory leak: MapWnd::m_mineral
    [FreeOrion/UI/MapWnd.cpp]: Memory leak: MapWnd::m_trade
    [FreeOrion/UI/MapWnd.cpp]: Memory leak: MapWnd::m_population
    [FreeOrion/UI/MapWnd.cpp]: Memory leak: MapWnd::m_research
    [FreeOrion/UI/MapWnd.cpp]: Memory leak: MapWnd::m_industry
    [FreeOrion/UI/MapWnd.cpp]: Memory leak: MapWnd::m_btn_siterep
    [FreeOrion/UI/MapWnd.cpp]: Memory leak: MapWnd::m_btn_research
    [FreeOrion/UI/MapWnd.cpp]: Memory leak: MapWnd::m_btn_production
    [FreeOrion/UI/MapWnd.cpp]: Memory leak: MapWnd::m_btn_design
    [FreeOrion/UI/MapWnd.cpp]: Memory leak: MapWnd::m_btn_menu
    [FreeOrion/UI/MapWnd.cpp]: Memory leak: MapWnd::m_FPS
    [FreeOrion/UI/MultiplayerLobbyWnd.cpp]: Memory leak: MultiplayerLobbyWnd::m_chat_box
    [FreeOrion/UI/MultiplayerLobbyWnd.cpp]: Memory leak: MultiplayerLobbyWnd::m_chat_input_edit
    [FreeOrion/UI/MultiplayerLobbyWnd.cpp]: Memory leak: MultiplayerLobbyWnd::m_galaxy_setup_panel
    [FreeOrion/UI/MultiplayerLobbyWnd.cpp]: Memory leak: MultiplayerLobbyWnd::m_saved_games_list
    [FreeOrion/UI/MultiplayerLobbyWnd.cpp]: Memory leak: MultiplayerLobbyWnd::m_players_lb
    [FreeOrion/UI/MultiplayerLobbyWnd.cpp]: Memory leak: MultiplayerLobbyWnd::m_start_game_bn
    [FreeOrion/UI/MultiplayerLobbyWnd.cpp]: Memory leak: MultiplayerLobbyWnd::m_cancel_bn
    [FreeOrion/UI/OptionsWnd.cpp]: Memory leak: OptionsWnd::m_current_option_list
    [FreeOrion/UI/OptionsWnd.cpp]: Memory leak: OptionsWnd::m_done_button
    [FreeOrion/UI/ProductionWnd.cpp]: Memory leak: ProductionWnd::m_production_info_panel
    [FreeOrion/UI/ProductionWnd.cpp]: Memory leak: ProductionWnd::m_queue_lb
    [FreeOrion/UI/ProductionWnd.cpp]: Memory leak: ProductionWnd::m_build_designator_wnd
    [FreeOrion/UI/ResearchWnd.cpp]: Memory leak: ResearchWnd::m_research_info_panel
    [FreeOrion/UI/ResearchWnd.cpp]: Memory leak: ResearchWnd::m_queue_lb
    [FreeOrion/UI/ResearchWnd.cpp]: Memory leak: ResearchWnd::m_tech_tree_wnd
    [FreeOrion/UI/ServerConnectWnd.cpp]: Memory leak: ServerConnectWnd::m_servers_lb
    [FreeOrion/UI/ServerConnectWnd.cpp]: Memory leak: ServerConnectWnd::m_find_LAN_servers_bn
    [FreeOrion/UI/ServerConnectWnd.cpp]: Memory leak: ServerConnectWnd::m_IP_address_edit
    [FreeOrion/UI/ServerConnectWnd.cpp]: Memory leak: ServerConnectWnd::m_player_name_edit
    [FreeOrion/UI/ServerConnectWnd.cpp]: Memory leak: ServerConnectWnd::m_ok_bn
    [FreeOrion/UI/ServerConnectWnd.cpp]: Memory leak: ServerConnectWnd::m_cancel_bn
    [FreeOrion/UI/SidePanel.cpp]: Memory leak: SidePanel::m_system_name
    [FreeOrion/UI/SitRepPanel.cpp]: Memory leak: SitRepPanel::m_sitreps_lb
    [FreeOrion/UI/TechTreeWnd.cpp]: Memory leak: TechTreeWnd::m_tech_tree_controls
    [FreeOrion/UI/TechTreeWnd.cpp]: Memory leak: TechTreeWnd::m_tech_detail_panel
    [FreeOrion/UI/TechTreeWnd.cpp]: Memory leak: TechTreeWnd::m_tech_navigator
    [FreeOrion/UI/TechTreeWnd.cpp]: Memory leak: TechTreeWnd::m_layout_panel
    [FreeOrion/UI/TechTreeWnd.cpp]: Memory leak: TechTreeWnd::m_tech_list

     
  • Geoff Topping

    Geoff Topping - 2009-01-05

    Most or all of the "Memory leak" reported by cppcheck are not. They appear to be the GG::Wnd contained within other GG::Wnd as children. These are newed in code of the parnet - usually the parent's constructor - and are are deleted in the parent's GG::Wnd::DeleteChildren() which is called from GG::Wnd::~Wnd. In GG, children of a wnd are owned by their parent, so the parent deletes the children if the parent is itself deleted.

     
  • Zach Laine

    Zach Laine - 2009-01-08
    • priority: 5 --> 3
    • assigned_to: nobody --> tzlaine
     
  • Zach Laine

    Zach Laine - 2009-01-08

    Numerous memory leaks fixed in Subversion. I'll keep this one open as a reminder.

     
  • Geoff Topping

    Geoff Topping - 2009-01-11

    Based on the Windows Task Manager, there may be some leaks in the SidePanel. If I alternate clicking on two unexplored systems (with nothing else open) the reported Memory by the task manager increases by about 100k for each click. This was repeated many times for the same two systems, so it's not just memory being allocated to initially load the star textures.

    Also, while on the map screen with just the sidepanel open to an unexplored systems, the task manager memory use was reported at about 68000k. After minimizing the FreeOrion window, this increased to 142000k, and has remained in that range after repeated restoring and re-minimizing. Ending the turn dropped memory use to about 133000k, but minimizing and unminimizing brought it back to near 142000k.

     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.





No, thanks