# SquaresR memory leak?

I have tried the following code in Mathematica 11.0.1.0 on my MacBook:

squaresR2[___] := $Failed;  Note the command squaresR2[n] = res -- this is memoization (caching). ### Solution We can clear all these memoized values and reload the SquaresR package as follows: ClearAll["NumberTheorySquaresRDump*"]; Get[SystemPrivate$SystemFileDir <>
SystemDumpfixfile["NumberTheorySquaresR"] <> "x"]


### Commentary

There used to be a more clear distinction between core functions and those in standard packages. Core functions were typically faster, often being at least partially implemented in C, and better integrated with things like ClearSystemCache. Standard package functions were slower, being written in high-level Mathematica code, and one would not expect them to be entirely integrated into the system.

In recent versions however standard packages have been deprecated and replaced by functions in the System context. At first one would think these are core functions but in many cases (e.g. SquaresR) they are not. I find this less desirable as one can no longer expect a System function to be fast or well integrated. So in this case I would not consider the "failure" of ClearSystemCache` to be a flaw, but rather I consider it a flaw in the recent namespace organization of Mathematica.

• With the revision of the RT, I have a feeling that things will get more clear in the future (but this is just a feeling). At the same time, we all know that the language will have to, at a given moment, embrace the open trends. And having a clear division between the core and the extremely big package (the other 98%...), is, in my opinion, a fundamental step (but this is just an opinion based on a feeling...). – P. Fonseca Jan 20 '17 at 14:13
• @P.Fonseca To what do you refer with the revision of the RT? You touch on something I have long hoped for: the separation of the core language into a stand-alone free distribution, hopefully with new refinements and improvements to performance and perhaps design. The huge function library would then become the commercial product built on top of this language. Is that what you hope for too? – Mr.Wizard Jan 20 '17 at 20:08
• That's it. Take a look at this youtu.be/pzjhFF0wJiw. I have also heard that they are touching the pattern matching artillery. A lot of this is for certainly motivated by the new compiler. I really hope that we will have this on M12 (that should be something like 2018...). This means that everything that is core is being cleaned up, and that everything we can compile within the RT scope will most likely get close to any other "natively" achievable performance and robustness... – P. Fonseca Jan 21 '17 at 14:06
• ...Then, we have to think on the following question: is the RT library an income competitor of Mathematica? If it isn't (and I don't think it can be), there's the unique opportunity to get to the 21st century business model, while keeping the financial independency of the 80's! – P. Fonseca Jan 21 '17 at 14:06
• @P.Fonseca A very interesting and encouraging presentation; thank you. – Mr.Wizard Jan 26 '17 at 14:59