<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Access Violation After Call to QVector::append]]></title><description><![CDATA[<p dir="auto">Hello. I have recently run into an issue while using QVector. After loading a QVector up with a bunch of values, a call to append results in an access violation. I believe that the post at <a href="https://www.google.com/url?q=https://bugreports.qt-project.org/browse/QTBUG-10108&amp;sa=U&amp;ei=Q6xqUvuxDZP29gTky4G4CA&amp;ved=0CB8QFjAJ&amp;client=internal-uds-cse&amp;usg=AFQjCNH95ZDbmMJ-rqtex_fRofdnyqF6CQ" target="_blank" rel="noopener noreferrer nofollow ugc">https://www.google.com/url?q=https://bugreports.qt-project.org/browse/QTBUG-10108&amp;sa=U&amp;ei=Q6xqUvuxDZP29gTky4G4CA&amp;ved=0CB8QFjAJ&amp;client=internal-uds-cse&amp;usg=AFQjCNH95ZDbmMJ-rqtex_fRofdnyqF6CQ</a> refers to the same behavior but they are interested in addressing a different piece of the issue. Examining the call stack reveals that there is a call to QByteArray::realloc which must fail because the result is a NULL pointer which Qt attempts to deallocate. This is obviously the source of the access violation but why did realloc fail?</p>
<p dir="auto">This is what my code looks like (basically):</p>
<p dir="auto">@<br />
QVector&lt;QVariant&gt; getRowData();</p>
<p dir="auto">QVector&lt;QVariant&gt; allData;<br />
QVector&lt;QVariant&gt; tempData;</p>
<p dir="auto">for (int r = 0; r &lt; 67000; r++) {<br />
tempData = getRowData();<br />
for (int c = 0; c &lt; tempData.size(); c++) {<br />
allData.append (tempData[c]);<br />
}<br />
}<br />
@<br />
I'm actually reading data from a csv file so just imagine that getRowData() is filling a QVector with a row of values from the file.<br />
The max values on the for-loops are approximately the dimensions of my csv file.<br />
If I use QList instead of QVector then there are no problems. Any ideas of what is happening?</p>
<p dir="auto">Thanks.</p>
]]></description><link>https://forum.qt.io/topic/33532/access-violation-after-call-to-qvector-append</link><generator>RSS for Node</generator><lastBuildDate>Mon, 21 Sep 2026 12:33:29 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/33532.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 25 Oct 2013 17:58:48 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Access Violation After Call to QVector::append on Mon, 28 Oct 2013 13:58:26 GMT]]></title><description><![CDATA[<p dir="auto">Thanks koahnig.</p>
]]></description><link>https://forum.qt.io/post/202127</link><guid isPermaLink="true">https://forum.qt.io/post/202127</guid><dc:creator><![CDATA[[[global:former-user]]]]></dc:creator><pubDate>Mon, 28 Oct 2013 13:58:26 GMT</pubDate></item><item><title><![CDATA[Reply to Access Violation After Call to QVector::append on Fri, 25 Oct 2013 20:12:25 GMT]]></title><description><![CDATA[<p dir="auto">Here you find details on the "growth strategies":<a href="http://qt-project.org/doc/qt-5.0/qtcore/containers.html#growth-strategies" target="_blank" rel="noopener noreferrer nofollow ugc">http://qt-project.org/doc/qt-5.0/qtcore/containers.html#growth-strategies</a> of QVector and QList</p>
]]></description><link>https://forum.qt.io/post/201931</link><guid isPermaLink="true">https://forum.qt.io/post/201931</guid><dc:creator><![CDATA[koahnig]]></dc:creator><pubDate>Fri, 25 Oct 2013 20:12:25 GMT</pubDate></item><item><title><![CDATA[Reply to Access Violation After Call to QVector::append on Fri, 25 Oct 2013 20:05:55 GMT]]></title><description><![CDATA[<p dir="auto">Lists do not have the requirement of continuous memory. Vectors have this requirement. Typical vector implementations have to reserve a certain "amount of memory":<a href="http://qt-project.org/doc/qt-5.0/qtcore/qvector.html#capacity" target="_blank" rel="noopener noreferrer nofollow ugc">http://qt-project.org/doc/qt-5.0/qtcore/qvector.html#capacity</a> right at the beginning. Otherwise  each append would require a complete new allocation of the vector's size + 1 element. I do not know the exact implementation of QVector, but it looks that you are hitting the capacity limit and probably capacity extension is basically doubling it. At a certain stage you simply hit the ceiling when the system is not able to extend and copy the old to the new vector.</p>
]]></description><link>https://forum.qt.io/post/201929</link><guid isPermaLink="true">https://forum.qt.io/post/201929</guid><dc:creator><![CDATA[koahnig]]></dc:creator><pubDate>Fri, 25 Oct 2013 20:05:55 GMT</pubDate></item></channel></rss>