From 3ad52b208aa5d637a249bbaaee3aa13fcb5566d2 Mon Sep 17 00:00:00 2001 From: NIkita-Ruzanov Date: Thu, 7 Apr 2016 22:48:11 +0300 Subject: Fix for high memory usage during loggin of large request (#1396) --- src/core/smtp/MCSMTPSession.cpp | 2 ++ src/objc/imap/MCOIMAPSession.mm | 4 +++- src/objc/smtp/MCOSMTPSession.mm | 4 +++- 3 files changed, 8 insertions(+), 2 deletions(-) mode change 100644 => 100755 src/objc/smtp/MCOSMTPSession.mm diff --git a/src/core/smtp/MCSMTPSession.cpp b/src/core/smtp/MCSMTPSession.cpp index 166a58cd..758f5c65 100644 --- a/src/core/smtp/MCSMTPSession.cpp +++ b/src/core/smtp/MCSMTPSession.cpp @@ -230,8 +230,10 @@ static void logger(mailsmtp * smtp, int log_type, const char * buffer, size_t si bool isBuffer = isBufferFromLogType(log_type); if (isBuffer) { + AutoreleasePool * pool = new AutoreleasePool(); Data * data = Data::dataWithBytes(buffer, (unsigned int) size); session->connectionLoggerNoLock()->log(session, type, data); + pool->release(); } else { session->connectionLoggerNoLock()->log(session, type, NULL); diff --git a/src/objc/imap/MCOIMAPSession.mm b/src/objc/imap/MCOIMAPSession.mm index bec998c8..2eba5cc0 100755 --- a/src/objc/imap/MCOIMAPSession.mm +++ b/src/objc/imap/MCOIMAPSession.mm @@ -42,7 +42,9 @@ public: virtual void log(void * sender, ConnectionLogType logType, Data * data) { - [mSession _logWithSender:sender connectionType:(MCOConnectionLogType)logType data:MCO_TO_OBJC(data)]; + @autoreleasepool { + [mSession _logWithSender:sender connectionType:(MCOConnectionLogType)logType data:MCO_TO_OBJC(data)]; + } } virtual void queueStartRunning() diff --git a/src/objc/smtp/MCOSMTPSession.mm b/src/objc/smtp/MCOSMTPSession.mm old mode 100644 new mode 100755 index 9406a719..04e3993b --- a/src/objc/smtp/MCOSMTPSession.mm +++ b/src/objc/smtp/MCOSMTPSession.mm @@ -38,7 +38,9 @@ public: virtual void log(void * sender, ConnectionLogType logType, Data * data) { - [mSession _logWithSender:sender connectionType:(MCOConnectionLogType)logType data:MCO_TO_OBJC(data)]; + @autoreleasepool { + [mSession _logWithSender:sender connectionType:(MCOConnectionLogType)logType data:MCO_TO_OBJC(data)]; + } } virtual void queueStartRunning() -- cgit v1.2.3