heap-memory

Infinite loop without accepting input

£可爱£侵袭症+ 提交于 2019-12-11 09:29:10
问题 I am writing a simple C++ Program which allocates dynamic memory to my Program and then deletes this memory. Here is my Program: #include <iostream> #include <new> using namespace std; int main () { int i,n; int * p; cout << "How many numbers would you like to type? "; cin >> i; p= new (nothrow) int[i]; if (p == nullptr) cout << "Error: memory could not be allocated"; else { for (n=0; n<i; n++) { cout << "Enter number: "; cin >> p[n]; } cout << "You have entered: "; for (n=0; n<i; n++) cout <

Understanding cuda heap memory limitations per thread

南笙酒味 提交于 2019-12-11 09:28:19
问题 This question is about heap size limitation in cuda. Having visited some questions concerning this topic, including this one: new operator in kernel .. strange behaviour I've made some tests. Given a kernel as follow: #include <cuda.h> #include <cuda_runtime.h> #define CUDA_CHECK( err ) __cudaSafeCall( err, __FILE__, __LINE__ ) #define CUDA_CHECK_ERROR() __cudaCheckError( __FILE__, __LINE__ ) inline void __cudaSafeCall( cudaError err, const char *file, const int line ) { if ( cudaSuccess !=

Is it bad manners to return a heap allocated pointer from a function?

天涯浪子 提交于 2019-12-11 08:24:38
问题 Before boost::shared_ptr , was it considered a bad practice to return a heap allocated pointer from a function, since the caller will be required to remember to free() that object? Or, was it considered "normal"? 回答1: I don't consider it bad practice, so long as your API also provides an equivalent XXX_free (or XXX_close , XXX_clearup , or whatever) function, that the client code can call when finished with the pointer. That way, you have a consistent, symmetrical API, in the sense that

Heap error while writing xls file with Apache POI

大兔子大兔子 提交于 2019-12-11 07:39:55
问题 I am using Apache POI to create an excel[.xls] file. Now an excel can have 65535 rows & 256 cols. I am trying to write the java code to write the xls file with 65535x256 cells. I am getting a heap error. The current heap conf is -Xms512m -Xmx1700m. RAM size is 3.5gb. What is the way out for me ? I am using HSSF* classes to write xls file. Stack Trace is (I have enabled the -verbose:gc option) [Full GC [Tenured: 1092288K->1092288K(1092288K), 3.3174494 secs] 1583807K->1583807K(1583808K), [Perm

Java Heap Space: Applets

ⅰ亾dé卋堺 提交于 2019-12-11 07:25:05
问题 I had to write a program to work for a 3000*3000 matrix. It was working only up to 600*600. So I ran my program by increasing heap size by java -Xms64m -Xmx1024m <class_name> Because initially the OutOfMemoryError was occurring. That solved the problem. Now this same program is used to plot values in Applets. So I made a package and imported it. But then the same error was coming as you can't run an applet. You can only type javac class_name.java and appletviewer class_name.java . So there

Best steps to debug a JavaScript heap out of memory error

让人想犯罪 __ 提交于 2019-12-11 06:32:47
问题 The Error: So I get something that looks like this: <--- Last few GCs ---> [53206:0x104800000] 14400 ms: Mark-sweep 854.6 (956.2) -> 854.6 (916.7) MB, 47.2 / 0.0 ms (average mu = 0.871, current mu = 0.000) last resort GC in old space requested [53206:0x104800000] 14445 ms: Mark-sweep 854.6 (916.7) -> 854.6 (915.2) MB, 44.3 / 0.0 ms (average mu = 0.754, current mu = 0.000) last resort GC in old space requested <--- JS stacktrace ---> ==== JS stack trace ========================================

How to pass a boxed slice (`Box<[T]>`) to a C function?

时间秒杀一切 提交于 2019-12-11 05:08:40
问题 I want to expose a "dynamic array" to a C function. The C function will own the data and later will call a function of mine to free the data. So it'll look something like the following: fn get_something(len: *mut usize) -> *mut u8; fn dealloc_something(data: *mut u8, len: usize); Internally I have a Box<[T]> ( my_vec.to_boxed_slice() ). I can get the size/length pretty easily, but I don't know which pointer I should return. If I pass the pointer returned from boxed_slice.as_mut_ptr() to Box:

java.lang.OutOfMemoryError: Java heap space for 100000 records

倖福魔咒の 提交于 2019-12-11 03:59:29
问题 Trying to write an excel file using the following code public static void main(String[] args) { XSSFWorkbook workbook = new XSSFWorkbook(); XSSFSheet sheet = workbook.createSheet("Book Data"); Map<String, Object[]> data = new TreeMap<String, Object[]>(); data.put("1", new Object[] {"ID", "NAME", "LASTNAME"}); for(int i=2;i<100000;i++) { data.put(String.valueOf(i), new Object[] {i, "Name"+i, "LastName"+i}); } Set<String> keyset = data.keySet(); int rownum = 0; for (String key : keyset) { Row

Is my memory enough?

非 Y 不嫁゛ 提交于 2019-12-11 02:44:15
问题 I am running a Java application and received this message: Exception in thread "main" java.lang.OutOfMemoryError: Cannot allocate new BytePointer(1200): totalBytes = 3G, physicalBytes = 7G at org.bytedeco.javacpp.BytePointer.<init>(BytePointer.java:103) at org.nd4j.compression.impl.NoOp.compressPointer(NoOp.java:73) at org.nd4j.compression.impl.AbstractCompressor.compress(AbstractCompressor.java:131) at org.nd4j.compression.impl.AbstractCompressor.compress(AbstractCompressor.java:103) at org

How can one force Rust to take ownership of memory allocated other than by its safe methods?

断了今生、忘了曾经 提交于 2019-12-11 00:49:00
问题 In his February 2018 note titled "Memory Safety in Rust: A Case Study with C", Will Crichton wrote: Rust provides the ability to take ownership of raw pointers, which we do using slice::from_raw_parts_mut and Box::from_raw which tells Rust to treat the memory pointer as a heap-allocated array. After transferring ownership, assuming the memory is valid and of the right size/type, Rust applies its usual memory safety and containment checks. The relevant part of his code to which the above