[NXC] Memory Leak

Discussion specific to NXT-G, NXC, NBC, RobotC, Lejos, and more.
Post Reply
muntoo
Posts: 834
Joined: 01 Oct 2010, 02:54
Location: Your Worst Nightmare
Contact:

[NXC] Memory Leak

Post by muntoo »

If you try to run the attached NxProfiler-Demo.rxe, you will witness a memory leak!

It rises at about:

Image

Or (n * (n + 1) / 2) * sizeof(ULONG) which is about 2 * n^2.
Attachments
NxProfiler.zip
(64.11 KiB) Downloaded 193 times
Image

Commit to LEGO Mindstorms Robotics Stack Exchange:
bit.ly/MindstormsSE


Commit to LEGO Stack Exchange: bit.ly/Area51LEGOcommit
afanofosc
Site Admin
Posts: 1256
Joined: 26 Sep 2010, 19:36
Location: Nashville, TN
Contact:

Re: [NXC] Memory Leak

Post by afanofosc »

I don't know what you are trying to report here. That your code uses more and more memory as you add elements to arrays?

John Hansen
Multi-platform LEGO MINDSTORMS programming
http://bricxcc.sourceforge.net/
muntoo
Posts: 834
Joined: 01 Oct 2010, 02:54
Location: Your Worst Nightmare
Contact:

Re: [NXC] Memory Leak

Post by muntoo »

afanofosc wrote:I don't know what you are trying to report here. That your code uses more and more memory as you add elements to arrays?
Yes, but I'm only adding one element (4 bytes), and the DataspaceSize rises by the amount described in the formula above. (For example, from 49 to 50 elements, it rises by a few hundred bytes instead of the expected 4.)

The third line on the display indicates the "delta" increase in DataspaceSize.

The memory should be recycled when not in use - I know it does that normally, but for some reason it's not happening in this case. Eventually, at ~86 elements, the program gives me File Error! -1.
Image

Commit to LEGO Mindstorms Robotics Stack Exchange:
bit.ly/MindstormsSE


Commit to LEGO Stack Exchange: bit.ly/Area51LEGOcommit
Post Reply

Who is online

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