Main Site Documentation

RLP memory on Panda


I’m working on a new project and am still in the designing phase.

For that, I would like to know if it is possible to allocate a buffer of 16384 bytes in RLP on a Panda (USBizi)?


Isn’t the RLP_SIZE on USBizi 10236 bytes ?


RLP_SIZE is the flash size that can be allocated.
He’s asking about the amount of RAM that can be allocated and addressed from the RLP program code.


You can if you do it with malloc or simply link it to a buffer on the C# side.

In RLP you allocate the memory for the buffer then release it when finished. So a 10k buffer would be:

  unsigned char*buffer = (unsigned char*)RLPext->malloc(10000*sizeof(unsigned char));

  int i;
  for(i = 0; i < 10000; i++) {
    buffer[i] = 0;

  buffer[10] = 50;
  unsigned char x = buffer[10];


To link a C# buffer to RLP you create a pointer on the RLP side and point the C# buffer to it:

//create pointer first
unsigned char *buffer;

//RLP function to link the C# buffer
int LinkBuffer(unsigned char*generalArray, void **args, unsigned int argsCount, unsigned int *argSize) {
	buffer= generalArray;
	return 0;

The only ram RLP needs to start is the 1 byte for the pointer or up to 4 for int or float.


@ Lurch

Really - good to know !

Enabling RLP will reserve about 10KB of the user RAM memory for RLP
RLP Address: 0x40000440. RLP Size: 0x000027FC.

Why do I think that this is RAM and not Flash. You can store the ELF on a SDCard or USB stick, or a resource on the managed space.

Anyways - may be you know better and I could be wrong

Someone please enlighten me.


@ Rajesh You are right both ways.

The RLP code can be stored anywhere but gets loaded into RAM when it’s actually used. The 10KB just counts toward the RLP program code and any pointers or buffers defined at the start. Once it’s loaded then it can get a pointer from the C# side or allocate whatever extra RAM it needs.


I might try to allocate the buffer in C# and just pass the pointer to RLP.

Thanks for your input!


Thanks Guys

That was some good information.


No that is bad! Do not allocate in c# and pass to c++, gc may move objects in ram.

What you need is to use RLP extensions to allocate the memory.


That’s good to know, so malloc in C++ then give C# the reference. I probably never had a problem the opposite direction because what I was using was constantly accessed and never went to GC.


There is the [italic]fixed[/italic] keyword in C# which “pins” a managed object in memory. That is, it will not be moved by GC.

I don’t know if MF supports the keyword.