I am writing the code for a gnuradio block and I use a lot of dynamic
allocation. The code isn’t finished yet but I thought I would ask this
question anyways. For an idea this is how the mallocs look like.
- (204 + 5 + 204) gr_complex arrays of size 2046 each
- 1 double array of size 2046
The reason why I have this is most of the data allocated in these arrays
reused and I don’t have to calculate it again and again. i thought
this data ready when the block is initialized will speed up the
Being pessimistic programmer I am circumspect about my method. What are
haha! I just realized that this is a great deal of memory used.
I am so dumb.
I guess I will have to calculate this on each iteration i use that data.
It looks like only about 7 MB of memory… (204 + 5 + 204) * 2046 * 8 +
- 8 = 6,776,352 bytes. It probably won’t play too well with your CPU
but that still shouldn’t be too much, right?
Also, since you only need to calculate once, I assume you will be
these arrays only once (e.g. in the constructor)… if you’re not
every time general_work is called, it should be even less of a problem.
myself haven’t had to malloc more than about 1MB of arrays in a block,
though, but I think it may be worth trying out.