<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>LPC MicrocontrollersのトピックLPC1830 sample code configTOTAL_HEAP_SIZE</title>
    <link>https://community.nxp.com/t5/LPC-Microcontrollers/LPC1830-sample-code-configTOTAL-HEAP-SIZE/m-p/680349#M27349</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I want to know the "&lt;SPAN&gt;configTOTAL_HEAP_SIZE&lt;/SPAN&gt;" in the LPC1830 freertos_blinky&amp;nbsp;sample project.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;#ifdef __CODE_RED&lt;BR /&gt;#define configTOTAL_HEAP_SIZE ( ( size_t ) ( 16*1024 ) )&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;How to decide the 16*1024&amp;nbsp;for&amp;nbsp;&lt;SPAN&gt;configTOTAL_HEAP_SIZE?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thanks&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Ken&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 24 Jul 2017 07:23:46 GMT</pubDate>
    <dc:creator>kensu</dc:creator>
    <dc:date>2017-07-24T07:23:46Z</dc:date>
    <item>
      <title>LPC1830 sample code configTOTAL_HEAP_SIZE</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/LPC1830-sample-code-configTOTAL-HEAP-SIZE/m-p/680349#M27349</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I want to know the "&lt;SPAN&gt;configTOTAL_HEAP_SIZE&lt;/SPAN&gt;" in the LPC1830 freertos_blinky&amp;nbsp;sample project.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;#ifdef __CODE_RED&lt;BR /&gt;#define configTOTAL_HEAP_SIZE ( ( size_t ) ( 16*1024 ) )&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;How to decide the 16*1024&amp;nbsp;for&amp;nbsp;&lt;SPAN&gt;configTOTAL_HEAP_SIZE?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thanks&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Ken&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 24 Jul 2017 07:23:46 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/LPC1830-sample-code-configTOTAL-HEAP-SIZE/m-p/680349#M27349</guid>
      <dc:creator>kensu</dc:creator>
      <dc:date>2017-07-24T07:23:46Z</dc:date>
    </item>
    <item>
      <title>Re: LPC1830 sample code configTOTAL_HEAP_SIZE</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/LPC1830-sample-code-configTOTAL-HEAP-SIZE/m-p/680350#M27350</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Ken Su,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; At first, I think you need to know the heap and stack:&lt;/P&gt;&lt;P&gt;The heap is memory set aside for dynamic allocation. Unlike the stack, there's no enforced pattern to the allocation and deallocation of blocks from the heap; you can allocate a block at any time and free it at any time. This makes it much more complex to keep track of which parts of the heap are allocated or free at any given time; there are many custom heap allocators available to tune heap performance for different usage patterns.&lt;/P&gt;&lt;P&gt;The stack is the memory set aside as scratch space for a thread of execution. When a function is called, a block is reserved on the top of the stack for local variables and some bookkeeping data. When that function returns, the block becomes unused and can be used the next time a function is called. The stack is always reserved in a LIFO (last in first out) order; the most recently reserved block is always the next block to be freed. This makes it really simple to keep track of the stack; freeing a block from the stack is nothing more than adjusting one pointer.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; Heap can be applied by the user, and it shoule be release by the user, take an example:&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 12pt;"&gt;p1 = (char *)malloc(10); &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 12pt;"&gt;p1 is in the heap.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 12pt;"&gt;About your question:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 12pt;"&gt;#define configTOTAL_HEAP_SIZE ( ( size_t ) ( 16*1024 ) )&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 12pt;"&gt;If the size_t is 4 byte, then the heap size is 4*(16*1024)=65536.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 12pt;"&gt;If you don't use the malloc, I think you don't need to assign so much heap size, you even can defined it as 0, if you don't want to use it.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 12pt;"&gt;#ifdef __CODE_RED&lt;BR /&gt;#define configTOTAL_HEAP_SIZE&amp;nbsp;&amp;nbsp;( ( size_t ) ( 16*1024 ) )&lt;BR /&gt;#else&lt;BR /&gt;#define configTOTAL_HEAP_SIZE&amp;nbsp;&amp;nbsp;( ( size_t ) ( 0 ) )&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 12pt;"&gt;The heap size for the whole MCU&amp;nbsp;normally is defined in the link file.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 12pt;"&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="17.jpg"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/27693iF80EF25F4BAE13A8/image-size/large?v=v2&amp;amp;px=999" role="button" title="17.jpg" alt="17.jpg" /&gt;&lt;/span&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Have a great day,&lt;BR /&gt;Kerry&lt;/P&gt;&lt;P style="padding: 0px; min-height: 8pt;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;-----------------------------------------------------------------------------------------------------------------------&lt;BR /&gt;Note: If this post answers your question, please click the Correct Answer button. Thank you!&lt;BR /&gt;-----------------------------------------------------------------------------------------------------------------------&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 25 Jul 2017 05:50:11 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/LPC1830-sample-code-configTOTAL-HEAP-SIZE/m-p/680350#M27350</guid>
      <dc:creator>kerryzhou</dc:creator>
      <dc:date>2017-07-25T05:50:11Z</dc:date>
    </item>
  </channel>
</rss>

