Home > Back-end >  Out of memory
Out of memory

Time:10-11

In a multithreaded environment use idhttp request data
, in the form of the debug program run soon prompt "out of memory", program stop in idhttp - & gt; The Get ()
The use of BCB version for xe2
See in the Windows task manager program memory nor have been growing
Is with () function returns the type of AnsiString and idhttp get related?

CodePudding user response:

May be the problem in your stream, you may get the content is too big

CodePudding user response:

Get the stream have limit how much?

CodePudding user response:

No code is a shot in the dark, as the key code look first,

CodePudding user response:

Because the code is more, also don't know that a piece of, first post a part use idhttp
 
AnsiString __fastcall CrnGetHTMLAreaText (AnsiString strUrl)
{
AnsiString res;
Ih=new TIdHTTP * TIdHTTP (NULL);
Ih - & gt; HandleRedirects=true;
Ih - & gt; ReadTimeout=20000;

TStringStream * sResponse=new TStringStream ();
Try
{
Ih - & gt; Get (strUrl, sResponse);
}
The catch (Exception & amp; E)
{
WriteLog (e.M essage);
The delete ih.
}

Ih - & gt; Disconnect ();
The delete ih.
Res=sResponse - & gt; DataString;

The delete sResponse;
return res;
}

CodePudding user response:

Try {} the catch (... )
Change
Try {
Ih - & gt; Get (strUrl, sResponse);
Ih - & gt; Disconnect ();
Res=sResponse - & gt; DataString;
}
__finally
{
The delete ih.
The delete sResponse;
}
Or don't want to put the abnormal distributed function, still use the try {} the catch (... )
Try {
Ih - & gt; Get (strUrl, sResponse);
Ih - & gt; Disconnect ();
Res=sResponse - & gt; DataString;
}
The catch (Exception & amp; E)
{
WriteLog (e.M essage);
The delete ih.
The delete sResponse;
}
The catch (... )
{
WriteLog (" unknow error in CrnGetHTMLAreaText ");
The delete ih.
The delete sResponse;
}
Return res;

Or you are using auto_ptr to manage memory in c + +, can avoid the abnormal problem,

CodePudding user response:

Ok, I study the auto_ptr in c + +