digitalmars.D.learn - Print RAM used by arrays
- Giovanni Di Maria (12/12) Dec 13 2018 Hi.
- Steven Schveighoffer (12/24) Dec 13 2018 array.sizeof. BUT I would caution that you have used fixed-sized arrays
- Giovanni Di Maria (5/5) Dec 14 2018 Thank you very much for your
Hi.
How can I know the amount of RAM allocated by a vector?
For example:
string[8][1000] array;
for(int i=0;i<1000;i++) {
    
array[i]=["1111","2222","3333","4444","5555","6666","7777","8888"];
}
how can I know the amount of bytes of above matrix?
Can I clean the memory ofter his use, without use GC?
Thank you to everybody
Giovanni Di Maria
 Dec 13 2018
On 12/13/18 4:32 PM, Giovanni Di Maria wrote:Hi. How can I know the amount of RAM allocated by a vector? For example: string[8][1000] array; for(int i=0;i<1000;i++) { array[i]=["1111","2222","3333","4444","5555","6666","7777","8888"]; } how can I know the amount of bytes of above matrix?array.sizeof. BUT I would caution that you have used fixed-sized arrays so they will NOT be allocated on the heap, but rather on the stack (or thread-local storage if it's a global). For a variable-sized array, such as string[8][], the .sizeof property is always going to be 2 words. For that case, you need to use the GC to ask for the block size: writeln(GC.sizeof(array.ptr));Can I clean the memory ofter his use, without use GC?It depends on where you put it. But generally D does not give back any memory to the OS unless asked to do so. But maybe that's not your question? -Steve
 Dec 13 2018
Thank you very much for your precious informations. Now i will try. Thank you!!! Giovanni
 Dec 14 2018








 
  
  
  Giovanni Di Maria <calimero22 yahoo.it>
 Giovanni Di Maria <calimero22 yahoo.it>