Open yangyongzhen opened 2 years ago
used qt 5.10.0, msvc2015 32bit,my qt project .pro file is:
#
#
QT += core gui concurrent
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
CONFIG += c++11
DESTDIR = $$PWD/./bin TARGET = log4qt_test
DEFINES += QT_DEPRECATED_WARNINGS
DEFINES +=LOG4QT_STATIC
LOG4QTSRCPATH = $$PWD/log4qt
INCLUDEPATH += -L $$LOG4QTSRCPATH \ $$LOG4QTSRCPATH/helpers \ $$LOG4QTSRCPATH/spi \ $$LOG4QTSRCPATH/varia
DEPENDPATH += $$LOG4QTSRCPATH \ $$LOG4QTSRCPATH/helpers \ $$LOG4QTSRCPATH/spi \ $$LOG4QTSRCPATH/varia
include($$PWD/log4qt/log4qt.pri) include($$PWD/log4qt/build.pri) include($$PWD/log4qt/g++.pri)
include(logger/logger.pri)
SOURCES += \ main.cpp \ mainwindow.cpp
HEADERS += \ mainwindow.h
FORMS += \ mainwindow.ui
qnx: target.path = /tmp/$${TARGET}/bin else: unix:!android: target.path = /opt/$${TARGET}/bin !isEmpty(target.path): INSTALLS += target
LIBS += -L$$PWD/./bin
i used heob tools in Qtcrator4.15, 64bit, the result is the same,both 32 bit and 64bit have the same probloms:
The more debug log info taked ,the more memory will be occupied
the test project can be downloaded from here: https://blog.csdn.net/yyz_1987/article/details/126017464
i have a problem when using log4qt in windows, The more debug or error log info taked ,the more memory will be occupied. is there any memory leak in windows? i just did a simple test by qtcreator project,using log4qt version 1.5.0
let me show the picture when running the test for one hour, the memory occupied from 6M to 456M
my log config is: log4j.rootLogger=DEBUG,daily,console
log4j.appender.logfile=org.apache.log4j.FileAppender log4j.appender.logfile.layout=org.apache.log4j.PatternLayout log4j.appender.logfile.layout.ConversionPattern=%-d [%t] %-5p: %m%n log4j.appender.logfile.File=./log/uiTest.log log4j.appender.logfile.ImmediateFlush=FALSE log4j.appender.logfile.Threshold=DEBUG log4j.appender.logfile.AppendFile=TRUE
log4j.appender.console=org.apache.log4j.ConsoleAppender log4j.appender.console.layout=org.apache.log4j.PatternLayout log4j.appender.console.layout.ConversionPattern=%-d [%t] %-5p: %m%n
log4j.appender.daily=org.apache.log4j.DailyFileAppender log4j.appender.daily.file=./log/uiTest.log log4j.appender.daily.appendFile=true log4j.appender.daily.datePattern=_yyyy_MM_dd
log4j.appender.daily.keepDays=90
log4j.appender.daily.layout=${log4j.appender.console.layout}
log4j.appender.daily.layout.dateFormat=${log4j.appender.console.layout.dateFormat}
log4j.appender.daily.layout.ConversionPattern=%-d [%t] %-5p: %m%n
log4j.appender.daily.layout.contextPrinting=${log4j.appender.console.layout.contextPrinting}
my test example is like this:
`void MainWindow::on_pushButton_clicked() { ui->pushButton->setEnabled(false); QFuture future = QtConcurrent::run([&]()
{
int count = 0;
while(1)
{
QMutex mutex;
QMutexLocker locker(&mutex);
logger->info("&&&&&on_pushButton_clicked&&&&&&&",FILE,FUNCTION,QString::number(LINE));
QThread::msleep(5);
count++;
}
});
}
void MainWindow::on_pushButton_2_clicked() { ui->pushButton_2->setEnabled(false); QFuture future = QtConcurrent::run([&]()
{
int count = 0;
while(1)
{
QMutex mutex;
QMutexLocker locker(&mutex);
logger->info("&&&&&on_pushButton_2_clicked&&&&&&&",FILE,FUNCTION,QString::number(LINE));
QThread::msleep(5);
count++;
}
});
}`