NXC command FreeMemory()

Discussion specific to NXT-G, NXC, NBC, RobotC, Lejos, and more.
mightor
Site Admin
Posts: 1079
Joined: 25 Sep 2010, 15:02
Location: Rotterdam, Netherlands
Contact:

Re: NXC command FreeMemory()

Post by mightor »

I believe the 128K excludes variables and non-code resources such as images in the FW. However, I am not the expert here. Perhaps John can shed some light on this.

- Xander
| My Blog: I'd Rather Be Building Robots (http://botbench.com)
| RobotC 3rd Party Driver Suite: (http://rdpartyrobotcdr.sourceforge.net)
| Some people, when confronted with a problem, think, "I know, I'll use threads,"
| and then two they hav erpoblesms. (@nedbat)
mattallen37
Posts: 1818
Joined: 02 Oct 2010, 02:19
Location: Michigan USA
Contact:

Re: NXC command FreeMemory()

Post by mattallen37 »

Ok, well I am just curious, I don't need to know specifically. I think your explanation makes sense.
Matt
http://mattallen37.wordpress.com/

I'm all for gun control... that's why I use both hands when shooting ;)
afanofosc
Site Admin
Posts: 1256
Joined: 26 Sep 2010, 19:36
Location: Nashville, TN
Contact:

Re: NXC command FreeMemory()

Post by afanofosc »

mattallen37 wrote:So, why does it return numbers no more than 106.644 kB? Does the firmware REALLY take up over half the flash? The AT91SAM7S256 has 256 kB of flash, so if I am only seeing less than half that, what is using up all the rest? I know that I have the program to read that number on it, but that only exists of the following.
The enhanced NBC/NXC firmware uses more flash memory than the standard NXT firmware does. This is because of all the additional opcodes and system calls that I have added. It uses 151,316 bytes of flash memory. 256k = 262144 bytes. Flash memory for user files is allocated in 256 byte chunks so every file will actually use a multiple of 256 bytes. 262144 - 151316 = 110828. If you delete all the files from the NXT and ask how much free memory there is using BricxCC's Diagnostic tool you should see a number similar to this.

John Hansen
Multi-platform LEGO MINDSTORMS programming
http://bricxcc.sourceforge.net/
mattallen37
Posts: 1818
Joined: 02 Oct 2010, 02:19
Location: Michigan USA
Contact:

Re: NXC command FreeMemory()

Post by mattallen37 »

Well, that makes a lot of sense. Thanks for explaining that.
Matt
http://mattallen37.wordpress.com/

I'm all for gun control... that's why I use both hands when shooting ;)
mattallen37
Posts: 1818
Joined: 02 Oct 2010, 02:19
Location: Michigan USA
Contact:

Re: NXC command FreeMemory()

Post by mattallen37 »

Ok, I must have missed that. Anyhow, would "GetCommModuleBytes(CommOffsetBrickDataBdAddr, 7,BID);" do exactly the same thing (with no void)? It seems to work, but I don't know if it is the same.

The help box(es) looks like the second picture "Win32 help".
Matt
http://mattallen37.wordpress.com/

I'm all for gun control... that's why I use both hands when shooting ;)
afanofosc
Site Admin
Posts: 1256
Joined: 26 Sep 2010, 19:36
Location: Nashville, TN
Contact:

Re: NXC command FreeMemory()

Post by afanofosc »

I've been told that if it looks like a duck and quacks like a duck then it's a duck. The inline wrapper function could be replaced by directly calling GetCommModuleBytes. That's how the NXCDefs.h header file defines GetBrickDataAddress.

John Hansen
Multi-platform LEGO MINDSTORMS programming
http://bricxcc.sourceforge.net/
Post Reply

Who is online

Users browsing this forum: Semrush [Bot] and 0 guests