locked
Platform String memory leak or i have wrong code.

    Question

  • Hi! I have a memory leaks when performing Platform::String::Concat method. To reproduce this i created metro style blank app. In App::OnLaunched method i added next code:
    Platform::String^ str1 = "String 1 String 1 String 1 String 1 String 1";
    Platform::String^ str2 = "String 2 String 2 String 2 String 2 String 2";
    Platform::String^ str12 = nullptr;
    int count = 20000;
    
    for(int i = 0; i < count; i++)
    {
    	str12 = str1 + str2;
    }

    Without this code blank app occupy near 9mb of memory. With this code it occupy 13mb of memory. With increasing count variable amount of memory for app will increase. I know that the "hat" operator is the smart pointer so str12 memory will be released every time i reassign it so there memory leak in concat method or i'm doing something wrong? With std::wstring everything works well.
    Monday, July 30, 2012 8:04 AM

Answers

  • Thanks for reporting this leak! This leak in concat was discovered after RP released.

    David Lamb

    • Marked as answer by sskr33 Tuesday, July 31, 2012 8:13 AM
    Monday, July 30, 2012 7:23 PM
    Moderator

All replies

  • Thanks for reporting this leak! This leak in concat was discovered after RP released.

    David Lamb

    • Marked as answer by sskr33 Tuesday, July 31, 2012 8:13 AM
    Monday, July 30, 2012 7:23 PM
    Moderator
  • Hopefully someone at Microsoft will update their regression tests to catch this problem, and similar leaks.
    Monday, July 30, 2012 11:58 PM