If you're using std::string/std::wstring contained in a std::map/std::set, there shouldn't be any leaking, unless you're doing something really wrong. The nice thing about std::string, set, map, etc. is that they help reduce the coded needed to avoid leaking. My main motive for suggesting std::set is that finding userIDs would be O(log(n)) instead of O(n)
Be sure that access to the container and its contents is thread-safe, of course.