Thanks to Prof. Ripley, my problem is really not a memory problem, but a
programming one. I should not use the old C-style memory allocation, but
something like
double *knn;
knn=Salloc(size,type);
especially when dynamically allocating. Although the compiling is a
little more complicated, it works perfectly. Now, with matrix 60000*12
and list 109*20*16, my script runs properly and S-plus never use more
than 60M memories.
BTW, perhaps because our mailing list doesn't allow for DLL attachment,
two of my posts to this list with DLLs attached had been killed. Sorry
for making you confused sometimes!
Thank you,
Yingfu
-----Original Message-----
From: Prof Brian Ripley [mailto:ripley@stats.ox.ac.uk]
Sent: den 18 februari 2005 15:20
To: Yingfu Xie
Cc: s-news@lists.biostat.wustl.edu
Subject: RE: [S] Memory problem in DLL?
Your code contains many lines like
double knn[dimension][*column]; // Array for the matrix with column
number *column.
which is not legal C. Try allocating your objects as described in the S
Programming Guide, or in `S Programming'.
If this is supposed to be C++ (the comments are C++ not C comments)
there
is another set of problems.
On Fri, 18 Feb 2005, Yingfu Xie wrote:
> Thank you, Prof. Ripley,
>
> Actually, I attached the DLL in my previous post, but it is taken away
> by the mailing list system, I believe. Now here come the C code and
DLL
> again.
None of us can read DLLs, can we? They don't run on Linux, either (not
that I would dream of running compiled code send to me by someone
unverifiable).
> Those who are willing to help or interested can have a try. Thanks a
lot
> in advance!
>
> Best regards,
> Yingfu
>
> -----Original Message-----
> From: Prof Brian Ripley [mailto:ripley@stats.ox.ac.uk]
> Sent: den 18 februari 2005 13:56
> To: Yingfu Xie
> Cc: s-news@lists.biostat.wustl.edu
> Subject: Re: [S] Memory problem in DLL?
>
> Without the C code it is hard for us to help.
>
> But in principle S-PLUS does not limit the memory available to a DLL,
> and
> some of mine (e.g. for isoMDS) can use very large amounts of memory).
>
> On Fri, 18 Feb 2005, Yingfu Xie wrote:
>
>> Hello, dear list members,
>>
>> I wrote a simple C code to get a matrix and list from S-plus, carry
> out
>> some calculation and return the result to S-plus. (I use .C routine
> and
>> only head file S.h is involved.) The main purpose is to speed up the
>> computation. It works.
>>
>> Now the problem is: when our data are just of moderate size, it
> refuses
>> to work any more. To be specific, our list is fixed and it has 109
>> elements which are matrix with 16 columns and 1~180 rows. The matrix
> has
>> 12 columns. In my PC, when the matrix has more than 1050 rows, the
> .C()
>> will always keep silence, just silence, and S-plus session is alive.
>>
>> Since the data are really not big, I doubt it is a memory problem
with
>> S-plus. Using Task Manager to track, S-plus never use much memory. So
> I
>> suspect maybe the memory used by the DLL is limited by S-plus in this
>> case, is it? Can any kind-heart tell me where I can find any
> information
>> for this and/or how to change it if it is possible? Is it machine or
>> compiler specified?
>>
>> I searched our archive and found quite a lot similar posts from late
>> 1990s; none of them had a clear answer. I really appreciate any hints
>> and efforts you make!
>>
>> My PC: P4 1.6G, 128M RAM; Windows 2000; S-plus6.2; Compiler: gcc
3.2.3
>> (mingw special 20030504-1)
>>
>> Thank you,
>> Yingfu
>>
>> Ps. I previous sent my post with my data attached, but it seems fail
> to
>> go through the firewall. Now, I attached a test example for those of
> you
>> who are interested, with the DLL and an S-plus script given, where
the
>> matrix data can be set as following:
>> rows<-3000 ##varying length of row
>> thematrix<-matrix(runif(rows*12),nc=12,nr=rows)
>>
>> In my test, it refuses to work when using more than 1064 rows of
>> thematrix.
>> Thank you again!
>> ###########################################
>>
>> This message has been scanned by F-Secure Anti-Virus for Microsoft
> Exchange.
>> For more information, connect to http://www.f-secure.com/
>
> --
> Brian D. Ripley, ripley@stats.ox.ac.uk
> Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/
> University of Oxford, Tel: +44 1865 272861 (self)
> 1 South Parks Road, +44 1865 272866 (PA)
> Oxford OX1 3TG, UK Fax: +44 1865 272595
> ###########################################
This message has been scanned by F-Secure Anti-Virus for Microsoft
Exchange.
For more information, connect to http://www.f-secure.com/
--
Brian D. Ripley, ripley@stats.ox.ac.uk
Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel: +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UK Fax: +44 1865 272595
###########################################
This message has been scanned by F-Secure Anti-Virus for Microsoft Exchange.
For more information, connect to http://www.f-secure.com/
|