Вниз
Скачать: CL | DM;

Кака освободить память?   Найти похожие ветки 

 
daos ©   (2002-09-11 05:54) [0]

Меня интересует можно-ли освободить память во время работы программмы. Т.е. серверное приложение, во время работы программы с клиентами она создает TMemoryStream и т.п., затем когда все клиенты отключатся мне бы хотелось освободить потерянную память (если она есть). try except finaly зделал но есть проблема: после того как я делаю

var
ms:TMemoryStream;
s:string;
begin
ms:=TMemoryStream.Create;
try
s:="Привет";
ms.write(s[1],length(s));
ms.position:=0;
ServerSocket1.Socket.Connections[i].SendStream(ms);
finaly
ms.free;
end;
end;

на инструкции ms.free вылазит ошибка доступа
Мне кажется, что здесь я теряю память, как этого избежать?


 
gek ©   (2002-09-11 07:38) [1]

хорошо бы сделать для начала ну примерно так


var
ms:TMemoryStream;
s:string;
begin
try
ms:=TMemoryStream.Create;
finaly
ms.free;
end;
end;

т е ничего не делать с потоком, глянуть возникает ли подобная ошибка


 
Digitman ©   (2002-09-11 09:04) [2]

Читаем хэлп !

Writes all the information that can be read from the AStream parameter to the socket connection.

function SendStream(AStream: TStream): Boolean;

Description

Use SendStream to write to the socket connection. The writing may occur in the OnSocketEvent event handler of a Windows socket object or in the OnWrite or OnClientWrite event handler of a socket component. Alternately, SendStream may write from a socket that is expected to write to the connection without a notification to signal the connection’s readiness to read. SendStream reads information from the stream indicated by AStream and writes it to the socket connection. The value returned by SendStream indicates whether any information was successfully written to the connection.


Note: The Stream passed as a parameter to SendStream becomes “owned” by the windows socket object. The Windows socket object frees the stream when it is finished with it. Do not attempt to free the stream after it has been passed as a parameter.



Страницы: 1 вся ветка

Скачать: CL | DM;



Память: 0.45 MB
Время: 0.01 c
7-34268
Дениска
2002-09-09 21:35
2002.11.11
Передача сообщений с одного компа на др.


1-34101
Sergy
2002-10-31 15:22
2002.11.11
Динамический массив. Найти индекс по значению


1-34117
ИгорьК
2002-10-31 15:07
2002.11.11
Доступ к форме Owner-у


14-34202
Rouse_
2002-10-22 12:04
2002.11.11
Скиньте плз на мыло msdn.hxa от MSDN за январь 2002


6-34142
CrazyAngel
2002-09-12 17:33
2002.11.11
Маленький e-мail :)




   Наверх