Главная страница
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.012 c
1-34117
ИгорьК
2002-10-31 15:07
2002.11.11
Доступ к форме Owner-у


14-34168
han_malign(damn it all)
2002-10-21 13:52
2002.11.11
Не вводил я никакого пароля, как мне под своим ником писать


6-34147
daan_m
2002-09-09 18:32
2002.11.11
Мастера помогите подключиться к Интернету


1-34118
TankMan
2002-10-30 21:41
2002.11.11
Люди поможите! Опять с хуками...


14-34238
AL2002
2002-10-23 11:02
2002.11.11
Пжалста. Не обидьте.