Vely logo Empower C
install  tutorials  examples
documentation  license  about

12.1.0 released on Sep 19, 2022



Free memory.


delete-mem <memory> status [ define ] <status>


delete-mem frees memory allocated by Vely. Do not use it on memory allocated by any C-library functions (such as malloc(), calloc() or realloc()).

delete-mem will handle memory violations or invalid pointers, and will not error out if there is an issue (Vely handles SIGSEGV, SIGBUS and SIGABRT signals typically raised for most issues). Rather, you can obtain the status of freeing memory in variable <status> by using "status" clause (you can create this number variable with "define" if it does not exist).

If <status> is VV_OKAY, the memory has been freed successfully. If <status> is VV_ERR_MEMORY, there was a problem; most likely <string> was not a valid memory pointer allocated by any of Vely statements; or it was a bad memory pointer for any number of reasons. Either way, delete-mem will not error out, and your program will continue.

Note that, in general, you should not free any memory used by your application, and that includes delete-mem statement.


Allocate and free memory:
new-mem define mystr size 300
delete-mem mystr status define st
if (st != VV_OKAY) {
    @Error in memory release!

Free memory allocated by write-string (consisting of 100 "Hello World" statements):
write-string define ws
    num i;
    for (i = 0; i < 100; i++) {
        @Hello World
delete-mem ws


Memory ( delete-mem   memory_handling   new-mem   resize-mem  )  SEE ALL (documentation)

Copyright (c) 2022 DaSoftver LLC. Vely is a trademark of Dasoftver LLC. The software and information herein are provided "AS IS" and without any warranties or guarantees of any kind. Icons copyright PaweĊ‚ Kuna licensed under MIT. This web page is licensed under CC-BY-SA-4.0.