Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

memory leak in windows? The more debug log info taked ,the more memory will be occupied #74

Open
yangyongzhen opened this issue Jul 27, 2022 · 3 comments

Comments

@yangyongzhen
Copy link

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
image
image

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++;
}
});
}`

@yangyongzhen
Copy link
Author

yangyongzhen commented Jul 27, 2022

used qt 5.10.0, msvc2015 32bit,my qt project .pro file is:
#-------------------------------------------------

Project created by QtCreator 2022-07-26T16:57:19

#-------------------------------------------------
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

@yangyongzhen
Copy link
Author

yangyongzhen commented Jul 27, 2022

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
image
b93e81b9353caeda60bd4aa36e38886

@yangyongzhen
Copy link
Author

the test project can be downloaded from here:
https://blog.csdn.net/yyz_1987/article/details/126017464

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant