Главная страница
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-33964
Igor__
2002-11-01 05:25
2002.11.11
Web Browser


14-34201
Yuraz
2002-10-22 12:34
2002.11.11
Можно ли загрузить архив этого форума в zip за месяц?


3-33895
Shrek
2002-10-22 18:55
2002.11.11
AutoCalc


1-33982
BIN
2002-10-31 14:44
2002.11.11
Конвертер Делфи6 -> Делфи3


4-34304
VepAlex
2002-10-02 06:21
2002.11.11
Не закрывается окно Дос приложения