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 ...
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 ...
24
votes
3answers
861 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 ...
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 ...
23
votes
4answers
1k views

What is the fastest way to count square-free words?

Background A word is a string of letters in an alphabet. A square-free word has no adjacent repeating substring. For example, (in the ternary alphabet of {0,1,2}) the words 00, 012121, and 0212012021 ...
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 ...
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 ...
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, ...
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 ...
20
votes
4answers
435 views

Running out of memory when partitioning an image with ImagePartition

I have an Image3D object of image type "Bit16" with the dimensions 1472 x 1472 x 1472 that I would like to split into small image cubes of dimension 64 x 64 x 64 ...
19
votes
3answers
667 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 ...
19
votes
2answers
703 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 ...
18
votes
3answers
518 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 ...
17
votes
3answers
706 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 ...
16
votes
2answers
271 views

Module trash collection behaviour

I have asked this question before on the Wolfram community forum (http://community.wolfram.com/groups/-/m/t/83845?p_p_auth=Gxoxe65B) but not with great success. Module creates temporary variables of ...
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 ...
15
votes
1answer
292 views

Why does this line increase the consumed memory?

Probably this is a simple question, however I really don't understand this behavior in Mathematica. It particularly leads to a memory leak in a huge program I have to do processing of 3D images. I ...
14
votes
1answer
509 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 ...
14
votes
1answer
308 views

How to constrain memory usage on HPC?

I found the performance of built-in function MemoryConstrained is very poor. It stops the evaluation after the memory limit has already been exceeded greatly than ...
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 ...
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
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 ...
11
votes
2answers
317 views

Memory leak in FE?

A very abridged example of what was originally a major leak ...
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 ...
10
votes
3answers
241 views

Can I return lists with different dimensions from a compiled function?

Sometimes I'll need several lists with different dimensions to be returned by a compiled function, but compiled function will fail if an irregular list contained: ...
9
votes
2answers
675 views

Avoiding an unresponsive user interface in OS X

I have found that despite Mathematica's numerous updates, each of which have added much functionality, one fundamental issue remains unaddressed: The unresponsiveness of the UI when I make a mistake ...
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 ...
9
votes
1answer
457 views

GeoDirection and GeoDistance Memory Leaks: How to Recover the Memory?

The functions GeoDirection and GeoDistance have memory leaks. To see this, run the example functions below and watch as the Physical Memory Available in the Windows Task Manager, Performance tab, ...
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
2answers
256 views

How to un-eat memory?

Consider this code: ...
8
votes
2answers
190 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 ...
8
votes
1answer
188 views

Reducing the memory footprint of lists of machine numbers

I have a large 1D dataset of double precision numbers that are stored in many external database files. In order to load the whole dataset into Mathematica 8 I iterate over the files ...
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: ...
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: ...
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 ...
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 ...
7
votes
2answers
183 views

How can I tell how much memory is taken by an expression?

ByteCount and LeafCount don't really work, as shown below. Mathematica 9.0 .. on a 32 bit Windows machine. ...
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 ...
7
votes
2answers
856 views

Memory running out generating ContourPlot3D

The code below ...
7
votes
1answer
714 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
1answer
565 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 ...
6
votes
2answers
320 views

Memory management and speed for Fast GCD

Let's say that we have some $300\,\text{K}$ digits (arbitrary function) and want to trial factor with $100{,}000{,}000$ first prime numbers. ...
6
votes
1answer
296 views

Optimizing Monte Carlo simulation of a Pred-Prey model

My assignment and code As part of an assignment for one of my classes, I'm trying to run a "massive" Monte Carlo simulation in Parallel on the follow model: ...
6
votes
1answer
130 views

Is there a version of Together that doesn't cancel common factors?

I'm running code that produces a long combination of rational functions with free constants that need to be tuned such that the combination vanishes. My current method is to put the combination over ...
6
votes
0answers
220 views

How can I find the source of a memory leak?

I found a really weird issue using NDSolve`ProcessEquations inside module. We start by setting HistoryLength to 0. After this we define a function which takes in an integer and creates a Table of ...
5
votes
2answers
164 views

Remove versus ClearAll

What is the difference between Remove and ClearAll? I thought that "not being recognized by Mathematica", which is the effect ...
5
votes
3answers
392 views

How do I find the amount of free space on disk?

I know a workaround, where one calculates sizes of all files and then you subtract this from your default space, but is there any direct way to do it? Simplicity and speed are important. There's the ...
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
495 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 ...