1
I am using Embarcadero RAD Studio 2010 Delphi.
I was doing tests to capture the screen images of other computers via sockets. Then I came across an error while capturing the screen and turning to JPG (or even recording as default BMP), after about 10 seconds - running a TTimer
400 interval error occurs:
[nameProjeto.exe] Raised Exception class Eoutofresources with message 'Insufficient storage space to process this command.'.
When you see the Timer event code, you will see that (for testing) I am just running the function CapturaTelaJpg
without saving it in anything (but it saves perfectly), and even then the error occurs after the 10 seconds.
function CapturaTelaJpg: TJpegImage;
var
dc : hdc;
cv : TCanvas;
aux : TBitmap;
begin
Result := TJPEGImage.Create;
aux := TBitmap.Create;
aux.Height := Screen.Height;
aux.Width := Screen.Width;
dc := GetDC(0);
cv := TCanvas.Create;
cv.Handle := dc;
//--Define o tamanho da imagem
aux.Canvas.CopyRect(Rect(0,0,Screen.Width,Screen.Height),cv,
Rect(0,0,Screen.Width,Screen.Height));
cv.Free;
cv := nil;
ReleaseDC(0,dc);
//-- Compacta o BMP para JPEG
Result.Assign(aux);
aux.Free;
aux := nil;
Result.Compress;
end;
Timer1
400-fold
procedure TfrmMonitorando.Timer1Timer(Sender: TObject);
begin
CapturaTelaJpg; // 10s depois, ocorre o erro colocando ou não numa variável
end;
Come on, first perform the procedure on your own PC, if the error occurs it has nothing to do with network, if it does not occur your problem is in the memory size used by client side! 2nd timer with interval 400 ????????????? ctz of that 400 is less than half a second, ie your timer is every second calling the same function 2 times.
– Junior Moreira
No matter the interval the error keeps occurring, it just takes a little longer to appear. And the test performed was not done on the network, is on my pc. For some reason Function is not downloaded from memory. Even if I put interval := 5000, the error appears anyway. It’s actually, every time he runs Function, he creates a Tjpegimage, right? Then I’d have to take that returned object out of memory. I’m not very experienced. I wanted to know how to recall this return.
– Grégori Sória
Put a Breakpoint in the function and debug it and tell where the bug is! Press F8 and see how far it can go!
– Junior Moreira
No no. you don’t understand. Function works perfectly. what’s going on is that it’s stacking memory.
– Grégori Sória