{"id":4845,"date":"2014-03-30T16:05:37","date_gmt":"2014-03-30T16:05:37","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/how-to-manage-large-buffer-in-c-collection-of-common-programming-errors\/"},"modified":"2014-03-30T16:05:37","modified_gmt":"2014-03-30T16:05:37","slug":"how-to-manage-large-buffer-in-c-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/how-to-manage-large-buffer-in-c-collection-of-common-programming-errors\/","title":{"rendered":"How to manage large buffer in C++?-Collection of common programming errors"},"content":{"rendered":"<p>When dealing with large amounts of memory, you have to look at two things, lifecycle, how often you create and recreate this buffer. As memory gets fragmented, there can come a time when you try to allocate a buffer of say, 512MB, and you can&#8217;t, because your allocator cannot find 512MB of contiguous address space. This is why @onebyone&#8217;s idea of using vectors is sometimes better. If you can reduce your footprint to byte-sized (not literally) chunks, you gain flexibility in how you manage your memory.<\/p>\n<p>That said, I would almost NEVER recommend keeping a large static buffer around. It&#8217;s asking for trouble.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>When dealing with large amounts of memory, you have to look at two things, lifecycle, how often you create and recreate this buffer. As memory gets fragmented, there can come a time when you try to allocate a buffer of say, 512MB, and you can&#8217;t, because your allocator cannot find 512MB of contiguous address space. [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-4845","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/4845","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=4845"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/4845\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=4845"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=4845"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=4845"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}