malloc() in general allocates memory dynamically. ie this does not lead to a determinate amount of memory being allocated by an executable, which would be the case if the executable only used statically allocate memory. If it runs for several hours and then crashes, it looks to me like the system cannot allocate the required memory after exhausting it all. Normally malloc() operates in conjunction with free() to release memory which is no longer needed.
Now, I have no idea of what you are doing, but if you are doing a script, you may well not be aware of malloc() and free() at work and the problem may well relate to how you are managing data or equally it could be some problem with how the things you are scripting deal with malloc() and free(). I really don't want to get into it deeper than this, but you need to look at the lifecycle of the data you are managing and not keep it one moment longer than necessary. You need to recognise that if data is allowed to grow without being culled, it will sooner or later eat up all the available memory.
A simple error you might be making is to call functions recursively. Recursion is possible in scripts as well as programming of binaries. It can be very powerful for handling some advanced data structures eg in object oriented programming, provided these are finite. It fails spectacularly at mathematical iteration [think of calculating constants to unlimited precision].
Now, I have no idea of what you are doing, but if you are doing a script, you may well not be aware of malloc() and free() at work and the problem may well relate to how you are managing data or equally it could be some problem with how the things you are scripting deal with malloc() and free(). I really don't want to get into it deeper than this, but you need to look at the lifecycle of the data you are managing and not keep it one moment longer than necessary. You need to recognise that if data is allowed to grow without being culled, it will sooner or later eat up all the available memory.
A simple error you might be making is to call functions recursively. Recursion is possible in scripts as well as programming of binaries. It can be very powerful for handling some advanced data structures eg in object oriented programming, provided these are finite. It fails spectacularly at mathematical iteration [think of calculating constants to unlimited precision].
Statistics: Posted by VinceL — Thu Mar 21, 2024 10:59 pm