summaryrefslogtreecommitdiffstats
path: root/src/corelib/tools
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@qt.io>2019-07-01 10:21:37 +0200
committerLiang Qi <liang.qi@qt.io>2019-07-01 19:20:20 +0200
commit57fccd6f2156e097fb902789a61731905487c543 (patch)
treed0114319e7016538d0ca4ffca2e77beb312b38e5 /src/corelib/tools
parent8f4baa3a223ad6f12101d5c4c10756a98d340ae6 (diff)
parentd25c3227299a6a281db37e68e45f0b02db3f5297 (diff)
Merge "Merge remote-tracking branch 'origin/5.13' into dev"
Diffstat (limited to 'src/corelib/tools')
-rw-r--r--src/corelib/tools/qbytearray.cpp17
-rw-r--r--src/corelib/tools/qiterator.h4
-rw-r--r--src/corelib/tools/qstring.cpp18
-rw-r--r--src/corelib/tools/qvector.qdoc18
4 files changed, 55 insertions, 2 deletions
diff --git a/src/corelib/tools/qbytearray.cpp b/src/corelib/tools/qbytearray.cpp
index c25d39461f..ecbb4743af 100644
--- a/src/corelib/tools/qbytearray.cpp
+++ b/src/corelib/tools/qbytearray.cpp
@@ -943,6 +943,23 @@ QByteArray qUncompress(const uchar* data, int nbytes)
and QByteArray() compares equal to QByteArray(""). We recommend
that you always use isEmpty() and avoid isNull().
+ \section1 Maximum size and out-of-memory conditions
+
+ The current version of QByteArray is limited to just under 2 GB (2^31
+ bytes) in size. The exact value is architecture-dependent, since it depends
+ on the overhead required for managing the data block, but is no more than
+ 32 bytes. Raw data blocks are also limited by the use of \c int type in the
+ current version to 2 GB minus 1 byte.
+
+ In case memory allocation fails, QByteArray will throw a \c std::bad_alloc
+ exception. Out of memory conditions in the Qt containers are the only case
+ where Qt will throw exceptions.
+
+ Note that the operating system may impose further limits on applications
+ holding a lot of allocated memory, especially large, contiguous blocks.
+ Such considerations, the configuration of such behavior or any mitigation
+ are outside the scope of the QByteArray API.
+
\section1 Notes on Locale
\section2 Number-String Conversions
diff --git a/src/corelib/tools/qiterator.h b/src/corelib/tools/qiterator.h
index 82212c3eb5..449d1049a0 100644
--- a/src/corelib/tools/qiterator.h
+++ b/src/corelib/tools/qiterator.h
@@ -115,11 +115,11 @@ template <class Key, class T> \
class Q##C##Iterator \
{ \
typedef typename Q##C<Key,T>::const_iterator const_iterator; \
- typedef const_iterator Item; \
Q##C<Key,T> c; \
const_iterator i, n; \
inline bool item_exists() const { return n != c.constEnd(); } \
public: \
+ typedef const_iterator Item; \
inline Q##C##Iterator(const Q##C<Key,T> &container) \
: c(container), i(c.constBegin()), n(c.constEnd()) {} \
inline Q##C##Iterator &operator=(const Q##C<Key,T> &container) \
@@ -148,11 +148,11 @@ class QMutable##C##Iterator \
{ \
typedef typename Q##C<Key,T>::iterator iterator; \
typedef typename Q##C<Key,T>::const_iterator const_iterator; \
- typedef iterator Item; \
Q##C<Key,T> *c; \
iterator i, n; \
inline bool item_exists() const { return const_iterator(n) != c->constEnd(); } \
public: \
+ typedef iterator Item; \
inline QMutable##C##Iterator(Q##C<Key,T> &container) \
: c(&container) \
{ i = c->begin(); n = c->end(); } \
diff --git a/src/corelib/tools/qstring.cpp b/src/corelib/tools/qstring.cpp
index 319f82af53..47db97cdfc 100644
--- a/src/corelib/tools/qstring.cpp
+++ b/src/corelib/tools/qstring.cpp
@@ -1739,6 +1739,24 @@ const QString::Null QString::null = { };
and the \c{'+'} will automatically be performed as the
\c{QStringBuilder} \c{'%'} everywhere.
+ \section1 Maximum size and out-of-memory conditions
+
+ The current version of QString is limited to just under 2 GB (2^31 bytes)
+ in size. The exact value is architecture-dependent, since it depends on the
+ overhead required for managing the data block, but is no more than 32
+ bytes. Raw data blocks are also limited by the use of \c int type in the
+ current version to 2 GB minus 1 byte. Since QString uses two bytes per
+ character, that translates to just under 2^30 characters in one QString.
+
+ In case memory allocation fails, QString will throw a \c std::bad_alloc
+ exception. Out of memory conditions in the Qt containers are the only case
+ where Qt will throw exceptions.
+
+ Note that the operating system may impose further limits on applications
+ holding a lot of allocated memory, especially large, contiguous blocks.
+ Such considerations, the configuration of such behavior or any mitigation
+ are outside the scope of the Qt API.
+
\sa fromRawData(), QChar, QLatin1String, QByteArray, QStringRef
*/
diff --git a/src/corelib/tools/qvector.qdoc b/src/corelib/tools/qvector.qdoc
index 4c442511ea..8765b7fbd6 100644
--- a/src/corelib/tools/qvector.qdoc
+++ b/src/corelib/tools/qvector.qdoc
@@ -173,6 +173,24 @@
For a detailed discussion comparing Qt containers with each other and
with STL containers, see \l {Understand the Qt Containers}.
+ \section1 Maximum size and out-of-memory conditions
+
+ The current version of QVector is limited to just under 2 GB (2^31 bytes)
+ in size. The exact value is architecture-dependent, since it depends on the
+ overhead required for managing the data block, but is no more than 32
+ bytes. The number of elements that can be stored in a QVector is that size
+ divided by the size of each element.
+
+ In case memory allocation fails, QVector will use the \l Q_CHECK_PTR macro,
+ which will throw a \c std::bad_alloc exception if the application is being
+ compiled with exception support. If exceptions are disabled, then running
+ out of memory is undefined behavior.
+
+ Note that the operating system may impose further limits on applications
+ holding a lot of allocated memory, especially large, contiguous blocks.
+ Such considerations, the configuration of such behavior or any mitigation
+ are outside the scope of the Qt API.
+
\sa QVectorIterator, QMutableVectorIterator, QList, QLinkedList
*/