Quantcast
Channel: R.NET
Viewing all articles
Browse latest Browse all 1634

New Post: Very curious (different) memory issue

$
0
0
Hello All!

So, thanks to the help of the community - I solved my last problem which was due to disposing of a handle which led to the gc() not being comprehensive.

All sorted!

Now I went to fix another issue (just one me picking up the wrong field as I record my results), and I ran into a very very strange one. Strange enough I think it might be a bug - but if not (or so) any workarounds anyone can offer me are muchly appreciated.

For more comprehensive code of mine you can see the last thread I wrote, but I don't think that's relevant. Here is a single difference which causes me to either run out of memory (leak), or otherwise complete successfully.

The code with the memory leak is -

DynamicVector testvar5 = rEngine.GetSymbol("mNames").AsVector();
NumericMatrix testvar14t = rEngine.GetSymbol("mCoef").AsNumericMatrix();

for (int i = 0; i < testvar14t.RowCount; i++)
{
    //got to 5th x on the below
    //string tempIvN = "(Intercept)";

    //just up to 1st on this fucker
    string tempIvN = testvar14t.RowNames[i];

    Single coeff = (Single)testvar14t[i, 0];
    Single pvalue = (Single)testvar14t[i, 3];

    if (Single.IsInfinity(coeff)) coeff = 0;
    if (Single.IsNaN(coeff)) coeff = 0;

    if (Math.Abs(coeff) < 1.0E-30) coeff = 0;
    if (Math.Abs(coeff) > 1.0E30) coeff = 0;

    if (Single.IsInfinity(pvalue)) pvalue = 1;
    if (Single.IsNaN(pvalue)) pvalue = 1;
    if (Math.Abs(pvalue) < 1.0E-30) pvalue = 0;
                                    
    DataRow oprNewRow = regnTable.NewRow();
    oprNewRow["SEC_ID"] = sid;
    oprNewRow["DAT_ID"] = c;
    oprNewRow["LINDEX_ID"] = x;
    oprNewRow["IVR_INDEX_ID"] = indVarCodes[tempIvN];
    oprNewRow["IVR_INDEX_COEFF"] = coeff;
    oprNewRow["IVR_INDEX_PVALUE"] = pvalue;
    regnTable.Rows.Add(oprNewRow);

}

testvar5.Dispose();
testvar5 = null;

testvar14t.Dispose();
testvar14t = null;
Switching around the comments, where the code works :
NumericMatrix testvar14t = rEngine.GetSymbol("mCoef").AsNumericMatrix();

for (int i = 0; i < testvar14t.RowCount; i++)
{
    //got to 5th x on the below
    string tempIvN = "(Intercept)";

    //just up to 1st on this fucker
    //string tempIvN = testvar14t.RowNames[i].ToString();

    Single coeff = (Single)testvar14t[i, 0];
    Single pvalue = (Single)testvar14t[i, 3];

    if (Single.IsInfinity(coeff)) coeff = 0;
    if (Single.IsNaN(coeff)) coeff = 0;

    if (Math.Abs(coeff) < 1.0E-30) coeff = 0;
    if (Math.Abs(coeff) > 1.0E30) coeff = 0;

    if (Single.IsInfinity(pvalue)) pvalue = 1;
    if (Single.IsNaN(pvalue)) pvalue = 1;
    if (Math.Abs(pvalue) < 1.0E-30) pvalue = 0;

    DataRow oprNewRow = regnTable.NewRow();
    oprNewRow["SEC_ID"] = sid;
    oprNewRow["DAT_ID"] = c;
    oprNewRow["LINDEX_ID"] = x;
    oprNewRow["IVR_INDEX_ID"] = indVarCodes[tempIvN];
    oprNewRow["IVR_INDEX_COEFF"] = coeff;
    oprNewRow["IVR_INDEX_PVALUE"] = pvalue;
    regnTable.Rows.Add(oprNewRow);

}

testvar5.Dispose();
testvar5 = null;

testvar14t.Dispose();
testvar14t = null;
It's as if looking at " string tempIvN = testvar14t.RowNames[i].ToString();" is killing me.


Why could this be, and how can I work around it ?


THANKS

Viewing all articles
Browse latest Browse all 1634

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>