Results 1 to 3 of 3

Thread: Memory lost

  1. #1

    Default Memory lost

    Hi.

    I'm the developer of OpenAlchemist. I'm looking for memory leaks in my game and I think I have found a bug in clanlib (but I have my own leaks too ^^).

    When the player change the game skin during execution, resource memory is not free (even if I explicitly ask to do it). This is a great problem since a skin can contain more than 30Mb of resource.

    I use ClanLib 1.0 on my Ubuntu 8.10

    Valgrind told me that :
    Code:
    ==17347== Invalid read of size 4
    ==17347==    at 0x42C9DC8: CL_WeakPtr<CL_ResourceManager_Generic, CL_ResourceManager_Generic>::operator==(CL_ResourceManager_Generic const*) const (in /usr/lib/libclanCore-0.8.so.1.0.0)
    ==17347==    by 0x42C94E7: CL_Resource::unload() (in /usr/lib/libclanCore-0.8.so.1.0.0)
    ==17347==    by 0x419E04D: CL_Sprite::~CL_Sprite() (in /usr/lib/libclanDisplay-0.8.so.1.0.0)
    ==17347==    by 0x41B09DB: CL_Font_Target_Sprite::~CL_Font_Target_Sprite() (in /usr/lib/libclanDisplay-0.8.so.1.0.0)
    ==17347==    by 0x41AF3B3: CL_SharedPtr_Deleter<CL_Font_Target, CL_Font_Target_Sprite>::~CL_SharedPtr_Deleter() (in /usr/lib/libclanDisplay-0.8.so.1.0.0)
    ==17347==    by 0x41AE043: CL_SharedPtr<CL_Font_Target, CL_Font_Target>::decrement() (in /usr/lib/libclanDisplay-0.8.so.1.0.0)
    ==17347==    by 0x41AE06C: CL_SharedPtr<CL_Font_Target, CL_Font_Target>::~CL_SharedPtr() (in /usr/lib/libclanDisplay-0.8.so.1.0.0)
    ==17347==    by 0x41E4D3B: CL_Font_Generic::~CL_Font_Generic() (in /usr/lib/libclanDisplay-0.8.so.1.0.0)
    ==17347==    by 0x41AEAED: CL_SharedPtr_Deleter<CL_Clonable, CL_Clonable>::~CL_SharedPtr_Deleter() (in /usr/lib/libclanDisplay-0.8.so.1.0.0)
    ==17347==    by 0x41ADE61: CL_SharedPtr<CL_Clonable, CL_Font_Generic>::decrement() (in /usr/lib/libclanDisplay-0.8.so.1.0.0)
    ==17347==    by 0x41ADE8A: CL_SharedPtr<CL_Clonable, CL_Font_Generic>::~CL_SharedPtr() (in /usr/lib/libclanDisplay-0.8.so.1.0.0)
    ==17347==    by 0x41ADEAE: CL_LazyCopyPtr<CL_Clonable, CL_Font_Generic>::~CL_LazyCopyPtr() (in /usr/lib/libclanDisplay-0.8.so.1.0.0)
    ==17347==  Address 0x71077c4 is 388 bytes inside a block of size 16,556 free'd
    ==17347==    at 0x40246EA: operator delete(void*) (vg_replace_malloc.c:342)
    ==17347==    by 0x42ABDBC: CL_InputSource_Zip_FileEntry::~CL_InputSource_Zip_FileEntry() (in /usr/lib/libclanCore-0.8.so.1.0.0)
    ==17347==    by 0x41D9C61: CL_PNGProvider_Generic::init() (in /usr/lib/libclanDisplay-0.8.so.1.0.0)
    ==17347==    by 0x41DA143: CL_PNGProvider_Generic::CL_PNGProvider_Generic(std::string const&, CL_InputSourceProvider*) (in /usr/lib/libclanDisplay-0.8.so.1.0.0)
    ==17347==    by 0x41D825D: CL_PNGProvider::CL_PNGProvider(std::string const&, CL_InputSourceProvider*) (in /usr/lib/libclanDisplay-0.8.so.1.0.0)
    ==17347==    by 0x419BBDF: CL_ProviderType_Register<CL_PNGProvider>::load(std::string const&, CL_InputSourceProvider*) (in /usr/lib/libclanDisplay-0.8.so.1.0.0)
    ==17347==    by 0x41DABEC: CL_ProviderFactory::load(std::string const&, std::string const&, CL_InputSourceProvider*) (in /usr/lib/libclanDisplay-0.8.so.1.0.0)
    ==17347==    by 0x41EABE0: CL_ResourceData_SpriteDescription::load_image(std::string const&) (in /usr/lib/libclanDisplay-0.8.so.1.0.0)
    ==17347==    by 0x41EBE60: CL_ResourceData_SpriteDescription::add_images(CL_SpriteDescription&, CL_Resource&) (in /usr/lib/libclanDisplay-0.8.so.1.0.0)
    ==17347==    by 0x41EF71C: CL_ResourceData_SpriteDescription::load_description() (in /usr/lib/libclanDisplay-0.8.so.1.0.0)
    ==17347==    by 0x41E6D32: CL_ResourceData_Sprite::on_load() (in /usr/lib/libclanDisplay-0.8.so.1.0.0)
    ==17347==    by 0x42C9453: CL_Resource::load() (in /usr/lib/libclanCore-0.8.so.1.0.0)
    ==17347== 
    ==17347== Invalid read of size 4
    ==17347==    at 0x42C9DC8: CL_WeakPtr<CL_ResourceManager_Generic, CL_ResourceManager_Generic>::operator==(CL_ResourceManager_Generic const*) const (in /usr/lib/libclanCore-0.8.so.1.0.0)
    ==17347==    by 0x42C94E7: CL_Resource::unload() (in /usr/lib/libclanCore-0.8.so.1.0.0)
    ==17347==    by 0x419DF9D: CL_Sprite::~CL_Sprite() (in /usr/lib/libclanDisplay-0.8.so.1.0.0)
    ==17347==    by 0x8056CF0: (within /usr/games/openalchemist)
    ==17347==    by 0x80548DA: (within /usr/games/openalchemist)
    ==17347==    by 0x805541B: (within /usr/games/openalchemist)
    ==17347==    by 0x8051F55: (within /usr/games/openalchemist)
    ==17347==    by 0x8064C2D: (within /usr/games/openalchemist)
    ==17347==    by 0x8051D0A: (within /usr/games/openalchemist)
    ==17347==    by 0x804E0DF: (within /usr/games/openalchemist)
    ==17347==    by 0x4045CA2: main (in /usr/lib/libclanApp-0.8.so.1.0.0)
    ==17347==  Address 0x73cde84 is 4 bytes before a block of size 32 free'd
    ==17347==    at 0x40246EA: operator delete(void*) (vg_replace_malloc.c:342)
    ==17347==    by 0x41E4DCE: CL_Font_Generic::~CL_Font_Generic() (in /usr/lib/libclanDisplay-0.8.so.1.0.0)
    ==17347==    by 0x41AEAED: CL_SharedPtr_Deleter<CL_Clonable, CL_Clonable>::~CL_SharedPtr_Deleter() (in /usr/lib/libclanDisplay-0.8.so.1.0.0)
    ==17347==    by 0x41ADE61: CL_SharedPtr<CL_Clonable, CL_Font_Generic>::decrement() (in /usr/lib/libclanDisplay-0.8.so.1.0.0)
    ==17347==    by 0x41ADE8A: CL_SharedPtr<CL_Clonable, CL_Font_Generic>::~CL_SharedPtr() (in /usr/lib/libclanDisplay-0.8.so.1.0.0)
    ==17347==    by 0x41ADEAE: CL_LazyCopyPtr<CL_Clonable, CL_Font_Generic>::~CL_LazyCopyPtr() (in /usr/lib/libclanDisplay-0.8.so.1.0.0)
    ==17347==    by 0x41ABEB7: CL_Font::~CL_Font() (in /usr/lib/libclanDisplay-0.8.so.1.0.0)
    ==17347==    by 0x41B0003: std::pair<int const, CL_Font>::~pair() (in /usr/lib/libclanDisplay-0.8.so.1.0.0)
    ==17347==    by 0x41B0026: __gnu_cxx::new_allocator<std::pair<int const, CL_Font> >::destroy(std::pair<int const, CL_Font>*) (in /usr/lib/libclanDisplay-0.8.so.1.0.0)
    ==17347==    by 0x41B006B: std::_Rb_tree<int, std::pair<int const, CL_Font>, std::_Select1st<std::pair<int const, CL_Font> >, std::less<int>, std::allocator<std::pair<int const, CL_Font> > >::_M_destroy_node(std::_Rb_tree_node<std::pair<int const, CL_Font> >*) (in /usr/lib/libclanDisplay-0.8.so.1.0.0)
    ==17347==    by 0x41B0101: std::_Rb_tree<int, std::pair<int const, CL_Font>, std::_Select1st<std::pair<int const, CL_Font> >, std::less<int>, std::allocator<std::pair<int const, CL_Font> > >::_M_erase(std::_Rb_tree_node<std::pair<int const, CL_Font> >*) (in /usr/lib/libclanDisplay-0.8.so.1.0.0)
    ==17347==    by 0x41B0141: std::_Rb_tree<int, std::pair<int const, CL_Font>, std::_Select1st<std::pair<int const, CL_Font> >, std::less<int>, std::allocator<std::pair<int const, CL_Font> > >::~_Rb_tree() (in /usr/lib/libclanDisplay-0.8.so.1.0.0)
    ^C==17347== 
    ==17347== ERROR SUMMARY: 121004 errors from 5 contexts (suppressed: 95 from 2)
    ==17347== malloc/free: in use at exit: 100,668,396 bytes in 32,057 blocks.
    ==17347== malloc/free: 277,436 allocs, 245,379 frees, 315,617,490 bytes allocated.
    ==17347== For counts of detected errors, rerun with: -v
    ==17347== searching for pointers to 32,057 not-freed blocks.
    ==17347== checked 36,066,744 bytes.
    ==17347== 
    ==17347== LEAK SUMMARY:
    ==17347==    definitely lost: 2,181,289 bytes in 8,734 blocks.
    ==17347==      possibly lost: 3,947,929 bytes in 4,984 blocks.
    ==17347==    still reachable: 94,539,178 bytes in 18,339 blocks.
    ==17347==         suppressed: 0 bytes in 0 blocks.
    ==17347== Rerun with --leak-check=full to see details of leaked memory.
    Maybe you could take a look at this

  2. #2
    ClanLib Developer
    Join Date
    May 2007
    Posts
    1,824

    Default

    Humm strange

    Ref: OpenAlchemist using ClanLib v2.0 -
    http://www.openalchemist.com/forum/v...p?pid=104#p104

    SDL is almost supported, just a couple of minor (cough!) bugs left (like no keyboard )

    When done, i'll quickly try to convert openalchemist to ClanLib V2.0, to see if that helps.

    ps. Valgrind does not work with ClanLib v2.0, it seg faulted the last time I tried it!

  3. #3
    ClanLib Developer
    Join Date
    May 2007
    Posts
    1,824

    Default

    converting openalchemist to clanlib 2.0, I spotted the memory leak:

    " CL_ResourceManager gfx("general.xml", new CL_Zip_Archive(sp -> filename), true); "

    Nothing destroys that new archive.

Similar Threads

  1. Problems with lost connections
    By Qwerto in forum Official ClanLib SDK Forums
    Replies: 2
    Last Post: 07-11-2008, 12:43 PM
  2. Collision data seems to be lost whenever I install a new version of NS
    By Uhfgood in forum Novashell Game Creation System
    Replies: 1
    Last Post: 07-08-2008, 10:39 PM
  3. Video Memory
    By EdK in forum Official ClanLib SDK Forums
    Replies: 2
    Last Post: 06-14-2008, 08:39 PM
  4. Memory Leaks
    By in forum Funeral Quest
    Replies: 9
    Last Post: 03-06-2007, 11:00 AM
  5. Prophesy of the Ancients - Lost Goblin
    By Skeeve1313 in forum Dink Smallwood HD
    Replies: 0
    Last Post: 02-04-2007, 07:41 PM

Bookmarks

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •