Questions about RAM usage, including optimizing memory use, avoiding and fixing leaks and releasing unused memory.

learn more… | top users | synonyms

29
votes
4answers
2k views

Aborting evaluation when the memory exceeds a certain limit

Sometimes when generating a lot of data the memory usage shoots beyond its physical realm and my laptop freezes. There is no way to stop Mathematica when this happens. Task manager (or its equivalent ...
23
votes
2answers
2k views

Debugging memory leaks

I've written my incredibly complex, incredibly elegant analysis function, that works great on small test data. But when I run it on my real (bigger) data set it keeps running out of memory. It turns ...
21
votes
4answers
2k views

Plotting large datasets

I have a lot of data (e.g., 64x8192), to plot and it consumes too much memory (more than 2 GB) causing Mathematica to return "no memory available". For example, ...
22
votes
3answers
1k views

How to place an image inside a notebook, with the minimum memory footprint?

When creating a notebook with images, like photos, the file tends to quickly get big, which makes it difficult to use the notebook format for training material containing a lot of images. Are there ...
24
votes
4answers
1k views

How to find out the (current) free memory on the system?

Is there any way in Mathematica to find out the currently free memory on the system Mathematica runs on (like the utility free shows on the command line)? I've ...
19
votes
3answers
669 views

DeleteDuplicatesBy is not performing as I'd hoped. Am I missing something?

Déjà vu: a new-in-v10 function should provide a better solution to an old problem, but my enthusiasm is curbed when I run timings. This time the function is ...
17
votes
3answers
707 views

How to clear parts of a memoized function?

I have a function of two variables, e.g.: f[a_, b_] := f[a, b] = something f[a - 1, b - 1] etc With the above code I used the concept of memoization to speed up ...
18
votes
3answers
519 views

Memory Leak in Frontend - anyone know a workaround?

When using Rasterize on a Graphics expression composed of many differently coloured Graphics objects memory is allocated in the frontend which is then not released or reused when a similar graphic ...
12
votes
2answers
1k views

How do you deal with very large datasets in Mathematica?

This question is in two related parts. The first is about dataset size, the second data wrangling. Part 1: I've built a naive Bayesian classifier on Mathematica. It uses ...
25
votes
1answer
3k views

Finding long strings of identical digits in transcendental numbers

Introduction Describing the three main streams of present-day mathematical philosophy (formalism, Platonism and intuitionism) in a well-known book, The Emperor's New Mind, R. Penrose says: ...it ...
3
votes
2answers
248 views

Storing result from nested Table in a File for further computations

Consider the following: Table[Table[x = 20; y = 30; 2 i x + 3 j y , {i, 10}], {j, 3}] Suppose I want the result of this nested Table to be stored to an ...
7
votes
1answer
715 views

Memory not freed after running Clear when using a Table

When I'm creating large lists with Table I see the memory footprint increasing. ...
7
votes
2answers
225 views

Clean up list of partial outputs for memory

Context I run long Mathematica sessions; sometimes I have Output up to Out[3000+]. Hence I would like to be able to clear out some previous outputs which do use lots of memory. Attempt I am aware ...
11
votes
1answer
530 views

Space-efficient null space of sparse array

I have a roughly 100,000 × 3,000 matrix (as a SparseArray) that I'd like to find the kernel (null space) of. It has about 500,000 nonzero entries, all -1 or 1. ...
11
votes
2answers
317 views

Memory leak in FE?

A very abridged example of what was originally a major leak ...
7
votes
3answers
558 views

How to fix this memory leak

I am using halirutan's code in this thread to unflatten a list. It works very well but the problem is that the Module's local function f is not deleted when the ...
9
votes
2answers
713 views

Why does this simple program leak memory?

I have a simple Mathematica program which writes some plots to image files for later conversion into a movie. Unfortunately, the program leaks so much memory that it quickly exhausts all 12G of RAM ...
8
votes
1answer
177 views

Where is my memory? — LibraryLink never returns the memory

This is an example LibaryLink code from Mathematica documentation, which takes an integer and return an integer list: ...
5
votes
1answer
75 views

How to relate memory usage with occupied positions of SparseArrays?

What is the relation of memory usage of a SparseArray and the number of its occupied positions? Let's say you build a 100.000.000 by 10 element SparseArray. And fill the two position 1/1 and ...
5
votes
1answer
154 views

Is it possible to lower the bitwidth of (floating point) numbers?

The answer to this question will most probably be a definite no. Nevertheless, I would like to know whether it is possible to represent reals in the memory on less than the standard 32 or 64 bits ...
24
votes
3answers
863 views

Smooth Peter de Jong attractor

Today I was playing with Peter de Jong attractor. At the bottom of the page I've linked there are beautiful examples like: My attempts are not so great: It is around 10^5 points. For more than ...
19
votes
2answers
704 views

Why does ImageData need four times more memory?

Background We are dealing with very large TIFF image files that are imported, processed and exported using Mathematica 9.0.1. Many of our algorithms only work with an array representation of the ...
21
votes
3answers
1k views

Does parallel programming use up large quantities of memory in Mathematica?

When I start Mathematica with a fresh kernel and load a program I am developing to analyze biology data, the amount of used system memory is 1.9 GB (free memory is 14.5 GB). These memory values are ...
14
votes
1answer
510 views

Efficient code for tallying entries in very large lists

I am dealing with data sets containing tens of millions of (hashable) entries and simply using the Tally function to count the frequency of each unique list element ...
15
votes
1answer
300 views

Unpacked eigenvectors of complex matrices

Edit: This bug is fixed in Mathematica 10.0.0 I want to calculate eigenvectors of a Hermitian matrix. For example ...
11
votes
1answer
254 views

Old values are not freed/garbage collected when you re-evaluate an assignment

For this code: (* Cell 1 *) generate := Module[{x}, x = Range[100 * 1000 * 1000]; x]; (* Cell 2 *) g = generate[]; MemoryInUse[] If I evaluate cell 2 ...
10
votes
2answers
218 views

Is there a way to control V10's undo length?

This may be a duplicate (if so I will remove this), but I was having trouble finding the relevant bit of documentation to fix it. I noticed that my FrontEnd memory ...
9
votes
2answers
521 views

Memory leak issues

I am working with noncommuting objects and basically I am using Mathematica to sort large expressions by normal ordering and simplifying them. To this end, I first create an object called ...
7
votes
1answer
567 views

Mathematica memory management for large arrays

I have come across a weird phenomenon in Mathematica when dealing with large arrays. When generating a list with all the possible subsets of three elements of another list (thus having elements which ...
8
votes
1answer
144 views

AndersonDarlingTest and DistributionFitTest Leaking Memory

I believe AndersonDarlingTest and probably all other tests are keeping a copy of data somewhere and not freeing it: ...
8
votes
2answers
256 views

How to un-eat memory?

Consider this code: ...
4
votes
3answers
220 views

Is there something wrong with this piece of code involving Manipulate?

I am playing around with the Manipulate sentence. I think the following code is right, and actually Mathematica 9.0 doesn't return any error message, but I am ...
4
votes
1answer
106 views

Memory usage of timeseries - lists of {Integer32, Real32}

A list of {Integer32, Real32} items in Mathematica seems to use 12-times as much memory than the C equivalent array of structs. ...
4
votes
2answers
339 views

Memory efficient generation and selection of tuples

The short of this question: I need to find a bunch of n-tuples of {0,1} which do not fail to satisfy a set of (non-linear polynomial) equations, without hogging up all of my memory by trying to ...
2
votes
3answers
129 views

Accessing temporary value of a Nest evaluation

The function Nest[] must store the temporary values in the memory somewhere (those values that would form the entries of the list which is returned by the ...
8
votes
2answers
191 views

Giving JLink Huge Memory by Default

I have noticed that Mathematica makes use of Java by way of JLink, for example, in the extensions such as DatabaseLink and (I think) RLink. It also seems like Java is a first-class citizen for writing ...
7
votes
2answers
670 views

Working with large data, pass-by-reference, compiled functions

I think I know the answer to this, but after two days of Googling, this is my last effort before going down an unwanted path... I have a function that takes lots of large data as arguments as well as ...
5
votes
1answer
498 views

Clear and Unset doesn't free memory

Example: Try this example only if you have > 4G ram d = 2000; f[x_, y_, d_] = Sum[Subscript[a, i, j]*x^i*y^j, {i, 0, d - 1}, {j, 0, d - i}]; Then ...
3
votes
0answers
65 views

Increasing MaxPoints in NDSolve results in memory issue

I am interested in increasing "MaxPoints" in NDSolve's "MethodOfLines" in attempt to increase the resolution of the plot of the solution of linearly damped wave equation with transparent boundary ...
2
votes
1answer
695 views

NDSolve runs out of memory

I need to solve a second order ODE numerically. The ODE depends on two parameters (a,b). Things work fine when 'a' is small, but for large 'a' the solutions are oscillating rapidly and Mathematica ...
1
vote
1answer
152 views

Running out of memory using FindMinimum with ParametricFunctions

I am running a pretty large optimization problem which actually consists of an outer an inner optmization problem. I use ParametricNDSolve for solving a ODE system. When the optimization is done, ...
0
votes
1answer
83 views

How can I resolve the insufficient memory to complete the computation problem for solving function with iterated variables?

I am trying to solve for a value x in a function where the variables varies with iterations of K. Also, there is one variable called "rvsum" which is updated with a certain formula as well. I have ...