×

Discussion Board

Results 1 to 6 of 6
  1. #1
    Nokia Developer Expert
    Join Date
    Jun 2006
    Posts
    28

    Question Memory leak std::string

    UHEAP_MARK is detecting memory leak in strings. Is this a known issue and is there a work around for this?

    Code:
    int main(void)
    {
        __UHEAP_MARK;
            {
            std::string fullpath("C:\\sys\\bin\\");
            fullpath += "any.exe"; // <--- Causes reallocation
            
            printf((char*)fullpath.c_str());
            }
    
    #ifdef __WINSCW__
        CleanupWSD();// Cleanup all WSD related allocations
    #endif
          
        __UHEAP_MARKEND;
        return 0;
    }
    I know that openc initializes WSD on its first invocation therefore it needs to be cleaned before __UHEAP_MARKEND. Therefore I added "CleanupWSD" call. But still I am getting the memory leak.

    When I digged further with the help of foundation code I came to know that cleanup of the internal memory is not happening for strings. The cleanup code is defined under "_STLP_DO_CLEAN_NODE_ALLOC" macro which is not defined.
    Is there a workaround so that I don't see this memory leak. I want to find other leaks in my program but because of this I am unable to proceed further.
    Last edited by dennis_george; 2011-01-21 at 09:26.

  2. #2
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,694

    Re: Memory leak std::string

    Quote Originally Posted by dennis_george View Post
    I know that openc initializes WSD on its first invocation
    Based on that, it may be a possible workaround to have this initializion outside the _UHEAP_MARK block. What happens if you put some dummy std::string before it (and test with/without CleanupWSD())?

  3. #3
    Nokia Developer Expert
    Join Date
    Jun 2006
    Posts
    28

    Re: Memory leak std::string

    CleanupWSD is added only after I realized there was a memeory leak. Earlier hooklogger was showing memory leak in locale used internally in string. When I added CleaupWSD that problem is resolved.

    Now the memory leak is happening in the internal memory used to store the string. This memory is allocated when I use "+=" and not during the construction of the string class. As I mentioned before during the destruction of the string class this memory is not freed because "_STLP_DO_CLEAN_NODE_ALLOC" macro is not defined.

  4. #4
    Nokia Developer Expert
    Join Date
    Jun 2006
    Posts
    28

    Re: Memory leak std::string

    Are there any Nokia OpenC developers on this forum?
    Last edited by dennis_george; 2011-02-02 at 09:03.

  5. #5
    Nokia Developer Expert
    Join Date
    Jun 2006
    Posts
    28

    Re: Memory leak std::string

    Is this a bug in Symbian OpenC? Since Symbian is no more open source is there a way to raise bug?

  6. #6
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,694

    Re: Memory leak std::string

    You can post it in the Feedback boards, the first ones you see when visiting http://discussion.forum.nokia.com - I would suggest either the Tools and SDK-s, or the platform (S60+S40) board there .

Similar Threads

  1. exception occurs when converting QString to std::string
    By kimitake in forum [Archived] Qt SDKs and Tools
    Replies: 4
    Last Post: 2010-04-29, 17:08
  2. Using TBuf<X> as c++ std string
    By StasV in forum Symbian
    Replies: 3
    Last Post: 2009-10-28, 13:59
  3. View contents of std::string in Carbide?
    By fmcgeough in forum Open C/C++
    Replies: 7
    Last Post: 2009-05-28, 22:03
  4. memory leak on emulator = memory leak on device
    By manmli in forum Mobile Java General
    Replies: 2
    Last Post: 2006-08-05, 19:54
  5. C Standard Library, String methods, Memory Leak?
    By hoopsman in forum Symbian Tools & SDKs
    Replies: 2
    Last Post: 2004-01-30, 14:35

Posting Permissions

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