memory-management

Why does Nil increase one enum size but not another? How is memory allocated for Rust enums?

有些话、适合烂在心里 提交于 2019-12-23 19:51:47
问题 If I define the following enums, Nil does not increase the size of the enum: use std::mem::size_of; enum Foo { Cons(~char) } enum Bar { Cons(~char), Nil } println!("{}", size_of::<Foo>()); println!("{}", size_of::<Bar>()); // -> 4 // -> 4 On the other hand: enum Foo { Cons(char) } enum Foo { Cons(char), Nil } Yields: // -> 4 // -> 8 What is happening when I define an enum? How is memory being allocated for these structures? 回答1: A naive approach to enums is to allocate enough space for the

android Low memory:no more background process ?? Need help

孤者浪人 提交于 2019-12-23 19:41:31
问题 I am facing the problem of low memory. Low memory:no more background process And here is the scenario. I am using a list which gets its data from a string array, it has a custom background, Clicking on item, the list gets another string array to display as second or third level. Information for three levels written in database. After third level, there are two more levels for which data is going to be fetched from web services, And that causes the low memory error. How can I get rid of the

When do Fortran module allocatable arrays go out of scope when loaded as a shared library?

早过忘川 提交于 2019-12-23 18:46:02
问题 I am calling a fortran subroutine from R as part of a more complex optimization problem. Currently, the subroutine is self-contained -- with an input of current parameter values and an output of function evaluation and gradient terms. I now wish to initialize an allocatable array as a shared module variable (prior to the optimization) that will be used (but not modified) by the subroutine during optimization. In this context, when would the shared allocatable array go out of scope or be

Detect whether application is quit by the OS because of low RAM

感情迁移 提交于 2019-12-23 16:23:47
问题 In the application I'm building, I need to detect the application quitting if and only if the application has been quit when its in the background because the OS is reclaiming memory. From my own experimentation, the onDestroy is called on EVERY instance. I've tried checking for isFinishing but I'm not 100% sure which situations this isolates it to. @Override public void onDestroy() { super.onDestroy(); Log.i("V LIFECYCLE", "onDestroy"); if (!isFinishing()) { // are we here because the OS

Access violation exception when deleting an array

别来无恙 提交于 2019-12-23 16:00:11
问题 I'm getting "Access violation reading location" exception when deleting the allocated memory as follow. I have a native dll compiled against Visual Studio 2010(toolset: v100) C++ compiler.I have a managed dll wrapper for it which is compiled against toolset v90 as I want to target .net 2.0. The managed wrapper passes the reference to pointer (double *&myArray) to one of the native dll function call, which internally creates a dynamic array and initializes the data. However, when managed

How does C# manage memory allocated by a new operator inside a loop?

戏子无情 提交于 2019-12-23 15:44:56
问题 For example: for (i=0;i<10;i++) { myclass = new myclass(); // do stuff with myclass } Questions: How will all the memory that has been allocated by doing 10 allocations in this case be retrieved? What will my memory footprint be at the end of execution? With delete functionality in C++, one had more control over this but in this case, for the second iteration, myclass would simply take a new allocation and move on? 回答1: Since there are no more references to each new object after the next

is the following new overload leaking memory?

末鹿安然 提交于 2019-12-23 15:17:31
问题 I have encountered the following code: class a { public: void * operator new(size_t l, int nb); double values; }; void *a::operator new (size_t l,int n) { return new char[l+ (n>1 ? n - 1 : 0)*sizeof(double)]; } From what I get it is then used to have an array like structure that start at "values": double* Val = &(p->a->values) + fColumnNumber; My question is : is there a memory leak? I am very new to overloading new operator, but I'm pretty sure that the memory allocated is not deallocated

Heap size overflow issues with sound clips

眉间皱痕 提交于 2019-12-23 13:13:51
问题 I'm creating an Android app that involves multiple short sound clips. At the moment, I'm using SoundPool to load my sound clips once a 2nd activity is begun by the menu activity. The problem I seem to be having is that once this secondary activity begins, the loading of the sound clips causes multiple heap size overflows and then after a bit the activity actually loads (the emulator never gives an error or a force quit). Would using the MediaPlayer help me here and keep these heap size

why showing .GIF image increase memory continuously?

前提是你 提交于 2019-12-23 12:59:38
问题 i am showing simple code sample. I showed an gif image in a Jlabel . When run the programme, TASK manager shows that memory is increasing continuously. Why it happens? Edited: try this code please... on show glass button, glass panel is shown with gif image and a hide glass button in it and with that memory will be started increasing. On clicking hide glass button, glass panel will be hidden and memory increasing will b stopped. @mKorbel : I had debugged it, the constructor will be called

android ndk hw debuggning memory

不想你离开。 提交于 2019-12-23 12:59:09
问题 Backgrond I am very experienced in C and pretty new to Android and Java, but this is rather environmental issues that programming. I have developed an administrative application in ANSI-C to be ported to any OS, just adding a UI in OS-dependent code. Well it uses quite some memory, especially for huge user files. I have a working Win32 program, trying to make an Android app using Android Studio with NDK. Android studio bundle NDK installation works fine I have installed and made a Win7