Главная страница
Top.Mail.Ru    Яндекс.Метрика
Текущий архив: 2002.11.11;
Скачать: 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 вся ветка

Текущий архив: 2002.11.11;
Скачать: CL | DM;

Наверх




Память: 0.47 MB
Время: 0.015 c
1-34117
ИгорьК
2002-10-31 15:07
2002.11.11
Доступ к форме Owner-у


14-34160
^Sanya
2002-10-23 20:30
2002.11.11
Программа по составлению расписания ВУЗа...


7-34274
Keplin Sergey
2002-09-07 22:13
2002.11.11
Background file copy...


7-34268
Дениска
2002-09-09 21:35
2002.11.11
Передача сообщений с одного компа на др.


3-33862
maras
2002-10-22 10:05
2002.11.11
Контекстный поиск в таблице