Главная страница
    Top.Mail.Ru    Яндекс.Метрика
Форум: "Система";
Текущий архив: 2002.11.11;
Скачать: [xml.tar.bz2];

Вниз

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

 
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;
Скачать: [xml.tar.bz2];

Наверх





Память: 0.45 MB
Время: 0.008 c
1-34051
Linder
2002-10-30 18:13
2002.11.11
TPageControl


1-34059
Эндрю2
2002-10-17 22:31
2002.11.11
Поиск по Doc файлам


1-33962
Tea_pot
2002-11-01 12:28
2002.11.11
Пишу games mahgong, и пытаюсь загрузить много Bitmap-ов в память


8-34124
Vladimir Prokofiev
2002-07-17 17:28
2002.11.11
Что за зверь TCanvas3D в Delphi 5


1-34091
Zergling
2002-10-30 06:15
2002.11.11
Как корректно завершить работу потоков в программе!?





Afrikaans Albanian Arabic Armenian Azerbaijani Basque Belarusian Bulgarian Catalan Chinese (Simplified) Chinese (Traditional) Croatian Czech Danish Dutch English Estonian Filipino Finnish French
Galician Georgian German Greek Haitian Creole Hebrew Hindi Hungarian Icelandic Indonesian Irish Italian Japanese Korean Latvian Lithuanian Macedonian Malay Maltese Norwegian
Persian Polish Portuguese Romanian Russian Serbian Slovak Slovenian Spanish Swahili Swedish Thai Turkish Ukrainian Urdu Vietnamese Welsh Yiddish Bengali Bosnian
Cebuano Esperanto Gujarati Hausa Hmong Igbo Javanese Kannada Khmer Lao Latin Maori Marathi Mongolian Nepali Punjabi Somali Tamil Telugu Yoruba
Zulu
Английский Французский Немецкий Итальянский Португальский Русский Испанский