There is a daemon for executing commands in conditions where the target server is already half dead: the memory has run out, descriptors, some other failure has occurred and even bash cannot start. At the moment, the utility is written in C with its own memory allocator (it stores it in advance - when everything is in order and then it works with the block already received).

I want to rewrite to rust for ease of expansion. However, my own allocators have not yet entered the standard and cannot use them.

The tasks that need to be done are small and I’ll have enough memory on the stack, without allocating it in the heap. Actually the question is: How can I write code on rust-stable that will work without add. memory queries?

Closed due to the fact that it is necessary to reformulate the question so that it was possible to give an objectively correct answer by the participants aleksandr barakin , Bald , user194374, Denis , Streletz 23 Jul '16 at 12:56 .

The question gives rise to endless debates and discussions based not on knowledge, but on opinions. To get an answer, rephrase your question so that it can be given an unambiguously correct answer, or delete the question altogether. If the question can be reformulated according to the rules set out in the certificate , edit it .

  • one of the indirect signs of a question “falling out” of the site’s theme is if it implies a yes / no answer. - aleksandr barakin
  • one
    I strongly doubt that something can be guaranteed here. All containers use a bunch, including strings and vectors. In my opinion, only the absence of stdlib can guarantee the absence of heaps: rurust.imtqy.com/rust_book_ru/src/no-stdlib.html . I advise you to ask in English stack - can someone from the developers answer. - aSpex
  • The question was reformulated so that the detailed answer was supposed. nostdlib is available only in nightly, i.e. also not yet suitable. - rekby
  • one
    Well, you can always use Vec::with_capacity(usize) and similar constructors for containers to store the necessary amount of memory in advance. - kstep
  • In general, if you don’t explicitly ask for a memory by the designer, then it’s out of the heap and doesn’t stand out. So you can just use only the structures and arrays on the stack, and never use all kinds of Vec and Box, and thus get that same guarantee of not using heaps. But if you really need the memory of the unknown when compiling the size, there's no way to get away from the heap. - kstep

0