View Full Version : Qt notify badalloc

13th November 2014, 08:56
I have a multithreaded application. I don't use iterational dynamic memory allocation (new/delete). Already I overloaded global new/delete and knew, that there are no memory leaks in cause of them. This app is eating memeory well and when it crashes (I reimplemented QApplication and notify() into it to catch exceptions) I got badalloc from QAbstractSocket. How to understand and correct memory leak. (Is there a notify overflow and why memory not released?) Where is the reason of this hell? Thank you for any help. I don't know what to do.

Here is last data from debugger:

Local variables
e std::bad_alloc &
[std::exception] std::exception
[vptr] 0x1885b48
[0] 0x17b3770 <std::bad_alloc::~bad_alloc()>
[1] 0x17b3748 <std::bad_alloc::~bad_alloc()>
[2] 0x17b3688 <std::bad_alloc::what() const>
event @0x1928dea8 QEvent
[vptr] 0x18854c8
[0] 0x16e90e8 <QEvent::~QEvent()>
[1] 0x16e9138 <QEvent::~QEvent()>
d 0x0 QEventPrivate *
m_accept 1 ushort
posted 0 ushort
reserved 0 ushort
spont 0 ushort
t 50 ushort
receiver QReadNotifier
[QSocketNotifier] QSocketNotifier
[QObject] QObject
snenabled true bool
sntype QSocketNotifier::Read (0) QSocketNotifier::Type
sockfd 1404 int
engine @0x193a21d0 QNativeSocketEngine
[QAbstractSocketEngine] QAbstractSocketEngine
[QObject] QObject
[vptr] 0x680fbc88
d_ptr @0x193a21d4 QScopedPointer<QObjectData, QScopedPointerDeleter<QObjectData>>
[QAbstractSocketEnginePrivate] QAbstractSocketEnginePrivate
[QObjectPrivate] QObjectPrivate
[QObjectData] QObjectData
connectedSignals @0x1bfc6344 quint32 [2]
[0] 0 quint32
[1] 0 quint32
connectionLists 0x0 QObjectConnectionListVector *
currentChildBeingDeleted 0x0 QObject *
currentSender 0x0 QObjectPrivate::Sender *
declarativeData 0x0 QAbstractDeclarativeData *
eventFilters <0 элементов> QList<QPointer<QObject>>
extraData @0x1c60f8a0 QObjectPrivate::ExtraData
propertyNames <0 элементов> QList<QByteArray>
propertyValues <0 элементов> QList<QVariant>
userData <0 элементов> QVector<QObjectUserData*>
objectName "" QString
pendingChildInsertedEvents <0 элементов> QVector<QWeakPointer<QObject>>
senders 0x0 QObjectPrivate::Connection *
sharedRefcount QAtomicPointer<QtSharedPointer::ExternalRefCountData>
threadData @0x1858f3f8 QThreadData
hasSetSocketError false bool
localAddress QHostAddress
localPort 28911 quint16
peerAddress QHostAddress
peerPort 56626 quint16
receiver QTcpSocketPrivate
socketError QAbstractSocket::UnknownSocketError (-1) QAbstractSocket::SocketError
socketErrorString "Unknown error" QString
socketProtocol QAbstractSocket::IPv4Protocol (0) QAbstractSocket::NetworkLayerProtocol
socketState QAbstractSocket::ConnectedState (3) QAbstractSocket::SocketState
socketType QAbstractSocket::TcpSocket (0) QAbstractSocket::SocketType
exceptNotifier 0x0 QSocketNotifier *
readNotifier QReadNotifier
socketDescriptor 1404 int
winSock QWindowsSockInit
writeNotifier QWriteNotifier
[QSocketNotifier] QSocketNotifier
engine @0x193a21d0 QNativeSocketEngine
str "Error std::bad_alloc sending event 6QEvent to object (13QReadNotifier)
this "QDevicesRunTester" @0x22fe0c QDevicesRunTestApplication

13th November 2014, 09:20
What memory leak do you mean? What does bad alloc have to do with memory leaks?

13th November 2014, 09:34
I mean that memory usage of appliacation in Windows task manager only increasing. It starts from 53 mb and when it become about 1 GB I get this crash.

13th November 2014, 10:00
So fix your code, I still fail to see any relation with exceptions. The problem is not when allocation fails but much earlier when you don't free memory you don't use.

13th November 2014, 13:05
What kind of problem I need to looking for? New/delete - ok. I don't overload events. For intercation between threads I use only signals and slots.

13th November 2014, 13:18
There is no point in guessing. Either use a memory profiler or analyze your code for allocated data you do not need. Be sure to use proper tools, Windows task manager is not a reliable tool for tracking memory consumption.