We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
Hello,
I am working with Teridian M6531 and I am trying to use memory allocation in my program. I was reading other forums and got the idea that init_mempool function should be used while using malloc. I did use that funtion too. But I am still not able to use malloc. It gives error when I use init_mempool function and it also gives error when I use malloc without init_mempool.
If anybody found such problem and got some solution, please let me know
Regards, Shrenik Mehta
I apologize for the incomplete post. Its a 80515 MPU. I almost solve the errors i used to get (would have mentioned it if i was still getting those). I am trying to use malloc() as I have big data structures within my program. When used as a local variable, those structure utilizes some part of my RAM. So I want to dynamically allocate memory for those structures. My program is working fine and I don't want to change it completely. Otherwise I would have broke those structures in smaller once.
Would welcome any suggestions to make my program more efficient.
Shrenik
Yes, of course they do - and if you allocate them dynamically they will use even more of your RAM! (dynamic allocation adds an overhead).
"I would have broke those structures in smaller once."
Eh??
One 100-byte structure occupies exactly the same amount of RAM as ten 10-byte structures (C51 adds no padding).
Dynamic allocation will certainly not make it any more efficient on an 8051!!
I am trying to use malloc() as I have big data structures within my program.
That's wrong in two separate ways. First, the size of data structures as such has no particular relation to whether they should be put into heap space. Second, it makes no sense to use an 8051 as your CPU if what you have really qualifies as "big data structures". You wouldn't hire a bicycle courier to haul 20 tons of timber half way across the continent, would you?
Thank you all. your suggestions are really helpful
Regards, Shrenik