Important Notice: Our web hosting provider recently started charging us for additional visits, which was unexpected. In response, we're seeking donations. Depending on the situation, we may explore different monetization options for our Community and Expert Contributors. It's crucial to provide more returns for their expertise and offer more Expert Validated Answers or AI Validated Answers. Learn more about our hosting issue here.

Huge memory waste using array of structs?

array huge memory structs waste
0
10 Posted

Huge memory waste using array of structs?

0
10

The following example was posted to the newsgroup: I’ve discovered to my horror that structs take up an obscene amount of overhead (I’m running version 5.3.1.29215a (R11.1) on a Dec ALPHA). I have a set of 10,242 observations, each consisting of 3+13=16 fields, which have 3*27 + 1*13 = 94 values. So the total size in bytes should be 10,242 * 94 * 8 bytes/double = 7,701,984. I have this stored in a 1 x 10242 data structure, and when I issue the whos command, it tells me that the data now takes up 27,367,136 bytes! Cris Luengo answers: My guess would be that a structure contains MATLAB arrays. Each array has some overhead, like data type, array sizes, etc. In your second implementation (index using data.latitude(observation)), there are 10,242 times less arrays allocated. Note that in your data, for each observation, you have 13 arrays with one value. I don’t know how large the matrix header exactly is, but it is a waste putting only a single value in it! I think Cris has hit it exactly.

0

=============================================== The following example was posted to the newsgroup: I’ve discovered to my horror that structs take up an obscene amount of overhead (I’m running version 5.3.1.29215a (R11.1) on a Dec ALPHA). I have a set of 10,242 observations, each consisting of 3+13=16 fields, which have 3*27 + 1*13 = 94 values. So the total size in bytes should be 10,242 * 94 * 8 bytes/double = 7,701,984. I have this stored in a 1 x 10242 data structure, and when I issue the `whos’ command, it tells me that the data now takes up 27,367,136 bytes! Cris Luengo answers: My guess would be that a structure contains MATLAB arrays. Each array has some overhead, like data type, array sizes, etc. In your second implementation (index using data.latitude(observation)), there are 10,242 times less arrays allocated. Note that in your data, for each observation, you have 13 arrays with one value. I don’t know how large the matrix header exactly is, but it is a

Related Questions

What is your question?

*Sadly, we had to bring back ads too. Hopefully more targeted.

Experts123