From c1fee1ab8859455b4c6475756967fe8bcc7a4b32 Mon Sep 17 00:00:00 2001 From: Yong-Dian Jian Date: Sat, 25 Sep 2010 13:46:16 +0000 Subject: [PATCH] in spqr_householder, use heap when the expected array size is greater than 2M bytes, otherwise, use local stack. Could have a better fix globally --- base/SPQRUtil.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/base/SPQRUtil.cpp b/base/SPQRUtil.cpp index 52180afc6..3552009ce 100644 --- a/base/SPQRUtil.cpp +++ b/base/SPQRUtil.cpp @@ -94,8 +94,17 @@ namespace gtsam { Stair[j] = m; } + + // YDJ: allocate buffer if m*n grows more than 2M bytes + const int sz = 250000; // the stack is limited to 2M, o + const int mn = m*n ; + double buf[sz] ; + double *a ; + if ( mn > sz ) a = new double [mn] ; + else a = buf ; + // convert from row major to column major - double a[m*n]; int k = 0; + int k = 0; for(int j=0; j sz ) delete [] a; + delete []Stair; cholmod_l_finish(&cc); }