Hello, this is probably something silly which I am doing, but I cannot
understand why this allocation is not happening.
Here is a my C code which tries to allocate a list of size 333559, and
then a matrix of size 8*333559
I thought I might be running into memory problems, but R is not even
using that much (I start R with
more memory and it stays constant) Also, I start R as I normally do and
I allocate a matrix of that size
and it returns instantly, so I am inclined to think that this is not a
memory/GC issue, but I submit it
may be.
<code>
int numHits = seq.GetNumberHits();
Rprintf("numHits:%d\n", numHits);
Rprintf("before allocation...\n");
SEXP oligos, matrix;
PROTECT(oligos = NEW_LIST(numHits));
Rprintf("allocated oligo list...\n");
PROTECT(matrix = NEW_INTEGER(numHits*8));
Rprintf("entering looop...\n");
<output>
entering sequence loop.
numHits:333559
before allocation...
allocated oligo list...
It hangs here everytime (never printing "entering loop..." - i have
waited like 10 minutes). If I remove the 8 then it completes.
Essentially I want to allocate a vector of that length and then
dimension it into a matrix, but I cannot see why this does not work.
debian 2.6
R 2.1.0
Thanks as always for any insight.
jim
James, On Jul 12, 2005, at 5:05 PM, James Bullard wrote:> Hello, this is probably something silly which I am doing, but I > cannot understand why this allocation is not happening.I suspect it's something else - the code you sent us works without problems for me: > .C("foo",as.integer(333559)) numHits:333559 before allocation... allocated oligo list... entering looop... [[1]] [1] 333559 > gc() used (Mb) gc trigger (Mb) max used (Mb) Ncells 162348 4.4 350000 9.4 350000 9.4 Vcells 60528 0.5 1453055 11.1 1562032 12.0 I have also tested it with 100-times larger vector and it works as well: > .C("foo",as.integer(33355900)) numHits:33355900 before allocation... allocated oligo list... entering looop... [[1]] [1] 33355900 > gc() used (Mb) gc trigger (Mb) max used (Mb) Ncells 162526 4.4 350000 9.4 350000 9.4 Vcells 60536 0.5 120333512 918.1 150162111 1145.7 This was on both Debian Linux and OS X, but that shouldn't really matter I suppose... (and I don't see why it should fail). If you overdo it with the size you can get "Error: cannot allocate vector of size xxx", but it won't hang, either. Cheers, Simon