55 of 59 menu

Data type stack

The stack data type is a fragment of RAM allocated for each data stream.

The stack works according to the LIFO principle. The essence of this principle is that the last piece of memory added to the stack will be the first to be removed from it.

The essence of working with a stack is that when a new variable is declared through a function, the first one is added to the stack. When the function finishes its work, the variable is automatically removed from the stack memory and the part it occupied becomes available to other objects.

The main advantage of the stack is the high speed of code execution, but the disadvantage is that when the memory allocated for the stack is full, the declared variables can no longer be changed and the code execution will stop. The stack size is set when the thread is created, and each variable has its own maximum memory size, which primarily depends on its data type. Because of this, it is necessary to declare the size of complex data types (for example, objects) in advance. Also, the stack can only hold local variables in memory; for global ones, a heap should be used.

See also

  • heap data type,
    which is widely used in programming
  • content delivery network CDN,
    which speeds up the loading of web application pages
  • a way of organizing data LIFO,
    which is widely used in programming
  • a way of organizing data FIFO,
    which is widely used in programming
English
AfrikaansAzərbaycanБългарскиবাংলাБеларускаяČeštinaDanskDeutschΕλληνικάEspañolEestiSuomiFrançaisहिन्दीMagyarՀայերենIndonesiaItaliano日本語ქართულიҚазақ한국어КыргызчаLietuviųLatviešuМакедонскиMelayuမြန်မာNederlandsNorskPolskiPortuguêsRomânăРусскийසිංහලSlovenčinaSlovenščinaShqipСрпскиSrpskiSvenskaKiswahiliТоҷикӣไทยTürkmenTürkçeЎзбекOʻzbekTiếng Việt
We use cookies for website operation, analytics, and personalization. Data processing is carried out in accordance with the Privacy Policy.
accept all customize decline