.bss is/are uninitialised static variables. // foo ends up in bss (because it is not explicitly initialised) // it's initial value is whatever the default 'zero' value for the type is. static int foo; // bar ends up in .data // (because) it is initialised with the value 42. static...
Excellent inquisitiveness. You're finding out what actually happens when a function is called, which is invaluable information. The stack is used for more than just storing local variables and function parameters. The exact layout of the stack contents is dictated by the ABI, an architecture specific description of how functions...
java,arrays,performance,memory,collections
Your theory is entirely possible. It does take the ArrayList a while to shrink the size of the internal array used to store the references. You can avoid that effect by using another List implementation like LinkedList that doesn't show this behavior, but those also have considerable memory overhead that...
Your second assumption is probably true for most of implementations. int A::get_member_var_a() will most probably be compiled to something like int __internal_compiler_prefix___A___get_member_var___thiscall(A* this) all a->fun() will be 'replaced' by compiler with fun(a). storing address to function inside instance is just too big overhead (couple of bytes per method per object)...
ruby-on-rails,ruby,ruby-on-rails-3,memory,heroku
That log excert is from a one off dyno, a la heroku run console - this is entirely seperate to your web dynos which you may be runnning 2x dyno's for. You need to specifiy --size=2x in your heroku run command to have the one off process use 2x dynos.
memory,memory-management,operating-system,paging,virtual-memory
If you have a page size of 4096, then page number = address DIV 4096 page offset = address MOD 4096 Those two values uniquely identify the logical memory location. Two addresses can be in the same frame. If that were not the case, there would be no point in...
As some of the comments mention, you are dereferencing a pointer that is pointing into an area of memory that it should not be. unsigned int *time = 0; is declaring a pointer to an unsigned integer, and the memory address it is pointing to is address 0x0. You are...
c++,string,c++11,memory,standards
Section 21.4.1.5 of the 2011 standard states: The char-like objects in a basic_string object shall be stored contiguously. That is, for any basic_string object s, the identity &*(s.begin() + n) == &*s.begin() + n shall hold for all values of n such that 0 <= n < s.size(). The two...
c,memory,gdb,64bit,32bit-64bit
Each memory location can only store eight bits, because the memory is byte addressable. A 64-bit machine doesn't give you 64 bits in every memory location, it simply means that it can naturally handle 64 bits at a time. For example, registers are 64 bits wide (unless you intentionally manipulate...
No, you cannot use an enhanced for loop to initialize the elements of an array. The declared variable, here x, is a separate variable that refers to the current element in the array. It's null here because you just declared the array. You are changing x to refer to a...
c#,exception,memory,ram,unhandled
Now that you've added all your code, your error is in this line: Console.WriteLine("{0}\n{1}\n{2}\n{3}\n{4}\n{5}\n",drivename,drivetype,driveformat,max_space,Available_space); You have 6 parameters, and only fill 5 of them. Each parameter must have a corresponding value(0-based index for 5 values is 0-4). See String.format and Console.WriteLine in MSDN for more info. So that line should...
Since T cached is declared inside the method I assume it is allocated on the stack, right? T being allocated in a method doesn't effect it being on the heap or the stack. The decision whether it is the former or the latter is based on whether this is...
I'm guessing that your SESSION_ENGINE setting is set to cache, and that you're using the development server. If so, then the behavior you're seeing makes perfect sense. When you change your Python code, the development server automatically restarts, losing all the data in memory. Since that includes the cache, which...
Yes, you're correct but I guess, this question needs a little more elaborated answer for why we are doing this. To start with, let's see what is done by the unary * operator. It dereferences it's operand based on the type of the operand. To elaborate in very simple terms,...
c++,arrays,pointers,memory,dynamic
Try changing your foo() like this and see the result: void foo(t* s) { delete[] s; // Additional memory allocation t* u = new t[2]; s = new t[2]; s[0].x = "FOO.X"; s[1].y = "FOO.Y"; } By adding another memory allocation, I moved s to another location in the memory,...
I found the issue myself. It's fairly easy. The "tr -cd '[:print:]'" removes line breaks and sort reads line by line. So it tries to read all the files as one line and the -S parameter can't do its job.
If you want to start gaming development on Android, I recommend you use a game framework built on top of OpenGL-es Look into LibGdx, it s a great starting point, so you don't reinvent the wheel and get productive right away: http://libgdx.badlogicgames.com/...
python,memory,iterator,out-of-memory
I am using 32bit python There's your problem. 32-bit processes, generally speaking, are limited to 4 GB of virtual memory each, minus kernel space, which can be significant. You will need to either switch to 64-bit computing or redesign your program to consume less memory. This is normally done...
If you don't initialize a reserved memory area it will contain any value that was stored there earlier. So it is always a good idea to "zero it", which means overwriting what ever was there with some value, in this case the null byte \0. If you replace malloc with...
I predict that your struct is being dynamically allocated via new or malloc and someone is either eating the std::bad_alloc exception without handling it or ignoring a NULL return. An address of 0x10 is almost certainly NULL plus the struct member offset. That would also explain the zeroed fields because...
int* array = new int(10); This creates one int with value 10... for 10 ints you want [10] not (10). Then I suggest you put in... std::cerr << "j " << j << '\n'; // add some trace array[j] = counter; ...and learn to debug. When you've got it working,...
Let's answer your questions one at a time: Question #1 - Can I limit the amount of time MATLAB takes to execute a script? As far as I know, this is not possible. If you want to do this, you would need a multi-threaded environment where one thread does the...
I fixed this issue by changing the Linux kernel version to 3.10 from 3.16.
c#,memory,memory-management,datatable
Your main problem is the behavior of the Garbage Collector is different depending on if you are debugging or in release mode without a debugger present. When in a debug build or a release build with a debugger present all objects have their lifetimes extended to the entire lifetime of...
For the main memory, the actual size of memory can be calculated as used+free+buffers+cache OR used+free+buffers/cache because buffers/cache = buffer+cache. The man page of used highlights as Used memory (calculated as total - free - buffers - cache) As the man page of free says :- total Total installed memory...
asp.net,iis,memory,console-application
The application pool (and yes IIS Express even has these) for the site that your .aspx page is running in is probably configured for 32 bit mode which is why it's returning 4GB and 3.3GB respectively. Being a 32 bit process that's all it can see. If you're running this...
User space processes only access the HighMem zone. The Normal and DMA zones (low mem) are privileged and directly accessed only by the kernel. The memory regions themselves may be laid out differently depending on if you're running a 32-bit or 64-bit machine, how much physical memory is installed, and...
android,android-fragments,memory,android-activity,picasso
Picasso has evictAll() API to clear cache. Also you can set Picasso disk cache size to something small or zero.
c,linux,memory,stack,portability
Q 1. why is ch empty even after fread() assignment? (Most probably) because fread() failed. See the detailed answer below. Q 2.Is this a portability issue between Solaris and Linux? No, there is a possible issue with your code itself, which is correctly reported by valgrind. I cannot quite...
python,django,python-2.7,memory,scrapy
You can process your urls by batch by only queueing up a few at time every time the spider idles. This avoids having a lot of requests queued up in memory. The example below only reads the next batch of urls from your database/file and queues them as requests only...
You'll have to subclass Stream, keep track of the stream's Position and the currently mapped segment: public class MmfStream : Stream { private IntPtr currentMap; private long mapOffset; private long mapSize; private long position; The Stream base class requires you to implement a Read and Write method, so whenever the...
18M vectors * 400 dimensions * 4 bytes/float = 28.8GB for the model's syn0 array (trained vectors) The syn1 array (hidden weights) will also be 28.8GB – even though syn1 doesn't really need entries for doc-vectors, which are never target-predictions during training. The vocabulary structures (vocab dict and index2word table)...
Due to JavaScript arrays actually being objects, memory is not contiguous. Thus, by your example, accessing array[1000] without ever storing anything elsewhere will take the same amount of memory as whatever you're storing (not 1000 * size of value). In fact, doing var arr = new Array(1000); per Danny's answer...
Your program exhibits undefined behavior since the member variables size, tail, and head of dlist are not initialized before being used. Use dlist() : dlist(0) {} dlist(int capacity) : cap(capacity), size(0), tail(nullptr), head(nullptr) {} That fixes the segmentation violation problem in my testing. I recommend adding a constructor to node...
memory,reverse-engineering,lldb
Thanks to @MarkPlotnick this works, mem read '*(int **)$r1' If you need to read a mem address at a certain offset, the following can be done, mem read '*(int **)($r1+4)' Tried and tested against Xcode debugging against ARMv7 and ARM64...
function,swift,memory,stack,heap
Both classes and closures are reference types. var foo = Foo() creates a Foo object on the heap, and stores a (strong) reference to that object in the local stack variable foo. return { foo } creates a closure which captures foo, so that the closure holds another (strong) reference...
java,android,eclipse,memory,libgdx
You may have to activate multidex, perhaps using play services exceeds the limited number of class for Dalvik "DEX". look this: https://developer.android.com/tools/building/multidex.html Somewhere I read this comment from a person something to fix a similar mistake, this is more or less what he said: I had a copy of Google...
ptr[i] means the value at address (ptr+i) so *ptr[i] is meaningless.You should remove the * Your corrected code should be : #include<stdio.h> #include<stdlib.h> #include<conio.h> int main() { int i; int *ptr; ptr=malloc(sizeof(int)*5); //allocation of memory for(i=0;i<5;i++) { scanf("%d",&ptr[i]); } for(i=0;i<5;i++) { printf("%d",ptr[i]); //loose the * } return 0; } //loose...
c,pointers,memory,memory-address
Any decent IDE that comes with debugger should allow you to view dereferenced value of an pointer. I am not familiar with CodeBlocks, but for instance Eclipse CDT does such thing pretty easily: By default it prints just *ptr, but you may set it to view as array of particular...
I still get the value of the Variable from the deleted object... No, you get a garbage value. By accessing terminData[0] after terminData.clear(); you've invoked undefined behaviour. Any suggestions how I could actually delete an object with its variable etc to get back the memory and create an new?...
Use GDB tool view available in KDevelop. In KDevelop 4.6, Window->Add ToolView->GDB will open the GDB tool view at the bottom/left/right of KDevelop IDE. Debug your program and at the point at which you have to check value of the variable, enter print variable_name in the textbox corresponding to GDB...
There are two factors in play java does not release managed heap memory eagerly. If you give it more room it may use that to run GCs less often (saves CPU cycles) NIO might be using off-heap memory (DirectByteBuffer) which is not released until the Buffers holding onto the memory...
As with (almost) anything, the way to find the optimal size for a particular parameter is to benchmark the workload you're trying to optimize with different values of the parameter. In this case, you'd need to run your code with different fetch size settings, evaluate the results, and pick the...
Slicing will copy the references. If you have a list of 100 million things: l = [object() for i in xrange(100000000)] and you make a slice: l2 = l[:-1] l2 will have its own backing array of 99,999,999 pointers, rather than sharing l's array. However, the objects those pointers refer...
It's more likely that you need to run your JVM with an increased maximum memory setting. The JVM will run with it's own limit on memory usage (subject to that available from the OS). e.g. $ java -Xmx2048m ... will run the JVM with a maximum memory setting of 2Gb....
The principle is stated in this answer: you need a finite state machine (FSM) which takes file bytes one by one as input and compares current input with a byte from the pattern according to FSM state, which is an index in the pattern. Here is the simplest, but naive...
c++,memory,parallel-processing,opencl
You are doing to mallocs that are never freed on each iteration of the loop. This is why you are running out of memory. Also, your loop is using an unsigned int variable, which could be a problem depending on the value of maxGloablThreads....
memory.limit is used to limit memory usage. It can be set to any value between 0 and the amount of available ram on the machine. The "correct" value for working with large data sets is the full amount of ram available. So, for example, with 4GB of ram, 4095 is...
The issue is not in the unzip code you had posted. the root couse is in: java.lang.OutOfMemoryError: Java heap space org.apache.commons.io.output.ByteArrayOutputStream.toByteArray(ByteArrayOutputStream.java:322) org.apache.commons.io.output.DeferredFileOutputStream.getData(DeferredFileOutputStream.java:213) org.apache.commons.fileupload.disk.DiskFileItem.getSize(DiskFileItem.java:289) Do you notice the ByteArrayOutputStream.toByteArray ? So it seems that you are writing to a ByteArrayOutputStream which grows too much. Please locate and post...
Since Spark runs on the JVM, just because Spark may no longer have any references to some memory doesn't mean that that memory will be freed. Even if a garbage collection has been triggered, the JVM may not release the memory back to the OS (this is controlled by -XX:MaxHeapFreeRatio...
c,arrays,memory,memory-management,malloc
If you try to do this in c or c++: int test[][]; you will get this error: error: declaration of 'test' as multidimensional array must have bounds for all dimensions except the first This is because test is not in fact a double ponter as you'd expect. But the compiler...
Lets say your program is in C Creating a large array is limited to the extent free memory is allowed and how the OS limits you. So let's say you created a pretty large array (uninitialized). Now that memory is given to your process(program you ran) and no other process...
c++,multithreading,memory,heap
No ... the thread shares memory with the main thread and all other threads started by the app. That is what makes multi-threading more difficult. You have to be careful when multiple threads access the same memory. Threads all share the same resources but only the main thread can interact...
The documentation tells you to pass high(SIZE_T). You do this when compiling for 32 bit, but not for 64 bit. This is what you mean to write: SetProcessWorkingSetSize(MainHandle, high(SIZE_T), high(SIZE_T)); Do note though that this code won't help performance on your machine. In fact, the only thing it can do...
cplusplus.com is notoriously bad... looking at cppreference.com's description here This function attempts to allocate a temporary buffer equal in size to the sequence to be sorted, typically by calling std::get_temporary_buffer. If the allocation fails, the less efficient algorithm is chosen. get_temporary_buffer is: template< class T > std::pair< T*, std::ptrdiff_t >...
pymatrix_to_CarrayptrsInt() calls ptrvectorInt() and this allocation is made if (!(result[i] = malloc(dim2 * sizeof(int)))){ then pymatrix_to_CarrayptrsInt() writes over that allocation with this assignment result[i] = &array[i * m]; causing a memory leak. If array is free()'d then attempting to free() result will fail
This happens when functions like fopen make a one time allocation. If you then call fopen again you will not get more leaks. Deleaker tries to hide such "known leaks" but sometimes they are still shown. Debugging this case I see that "leak" comes from this code inside CRT: int...
python,memory,multiprocessing,mpi,mpi4py
Use the resource module to query for current memory usage. Then, somewhere in your MPI program, dump the usage to a log at certain intervals. For example, the following measures maximum resident memory size of the current process, and appends the value to a file. What you would presumably do...
php,apache,memory,memory-management,out-of-memory
So it turns out the memory limit was being increased properly, just not being reflected in phpinfo(). The reason it was not reflecting in the phpinfo() echo, is because I was making the memory increase in the controller, and then echoing phpinfo() from the view, so the increase was not...
android,memory,memory-management,parse.com,allocation
If you are using parse.com and getting the Images from database and converting it to bitmaps it will crash your app.. what you should do is, get the image of the URL from parse.com there is method called.. ParseFile.getUrl(); For that implement the Picasso library, which is perfect solution for...
c#,.net,performance,memory,real-time
Can this behaviour be improved (easily)? Yes (depends on how much you need to improve it). The first thing I would do is to change Sample and ComplexSample to be value-types. This will reduce the complexity of the graph dealt with by GC as while the arrays and linked...
algorithm,memory,graph,compiler-optimization,directed-acyclic-graphs
Actually, in some sense this problem is easier than the graph coloring problem, because the decision version of this problem is a special case of the decision version of the Combined Register Allocation and Instruction Scheduling Problem (CRISP), which is simpler to solve than the graph coloring problem (at least...
c++,class,object,memory,instance
As @R and @Rupesh mentioned, you are seeing the behavior that's undefined. However, if I may provide you with a little more explanation about what's going on in your very specific code in that specific environment, this might be it. After I killed instance "lucife" the first time, why did...
python,google-app-engine,memory
GAE Mini Profiler does provide memory stats if you use the sampling profiler and set memory_sample_rate nonzero; at each snapshot it will tell you the memory that was in use. You will want to turn the sample frequency way down as the memory sample takes a few ms to execute....
Step 1: Identify where it happens. Compile with $ g++ -std=c++0x -Wall -O0 -g3 psinkt.cpp -o ./psinkt.out and debug with $ gdb ./psinkt.out gdb> run Or use valgrind $ yum install valgrind # or $ apt-get install valgrind $ valgrind --tool=memcheck ./psinkt.out Step 2: Improve your C++ I'd strongly encourage...
Why do programs consume disk space? I know the basics behind this, allocating space on a heap/stack, then deallocating them after use. But if this is the case, then the disk should not be used up, right? In fact, it can be used up. Memory allocations can consume hard-disk...
matlab,memory,sparse-matrix,allocation
Thanks to @horchler, I've found a solution. Even if MATLAB pre-allocates all the memory it needs before the execution, spparams('spunomi', 3) shows the peaks inside the allocation. Also by doing [L,U,P,Q,R] = lu(A) and then calculating the difference between the number of nonzero elements in L and the number of...
I think you are conflating two concepts. A struct should be repr(C) if you wish for the layout of the struct to directly correspond to the layout of the struct as a C compiler would lay it out. That is, it has the same in-memory representation. However, you don't need...
Paging always happens. It's just a mechanism of mapping virtual memory. Swapping is "paging + disk I/O", so therefore no, paging is neither an alternative to swapping nor can be slower than swapping itself.
What does it have to do with memory? It has to do with memory addressing, which is done using binary numbers as well. On a very high level, a typical memory chip works like this: it has pins of three types - address pins, data pins, and control pins....
Swap isn't a filesystem (like e.g. ext3) and thus isn't mounted in the normal sense. Use "swapon -s", it will confirm the numbers from the "free" output.
Why MapViewOfFile fails As IInspectable's comment explains freeing memory allocated with malloc doesn't make it available for use with MapViewOfFile. A 32-bit processes under Windows has a 4 GB virtual address space and only the first 2 GB of it is available for the application. (An exception would be a...
Yes, this is correct. The only danger would be generating a bit pattern that does not correspond to any int, but on modern systems there are no such patterns. Also, if the data type was uint32_t specifically, those are prohibited from having any such patterns anyway. Note that the inverse...
If both of the computers are 32 bits, they are practically both 4 GB RAM (unless you did weird things to solve it, like having PAE enabled). 32-bit operating system usually cannot handle more than 4 GB RAM. Besides, Out of Memory exceptions are thrown by the operating system not...
NO it does not contain the kernel portion of memory.
memory,memory-management,linux-kernel,kvm
No. Almost any physical page frame can be mapped to a userspace virtual address or a kernel virtual address, or even both at the same time....
From here: [a] /proc/meminfo - This file reports statistics about memory usage on the system. It is used by free to report the amount of free and used memory (both physical and swap) on the system as well as the shared memory and buffers used by the kernel. You can...
c,memory,dart,dart-native-extension
Maybe problem in that the in first case you allocate an array on the stack? If you will use a reference to this array outside of the function (after when a function returns) you will always get a segmentation fault. Please give a small example of the use of your...
The possible range of virtual addresses is processor and kernel and ABI specific. But I strongly advise against coding some tricks related to some bits in addresses and pointers (since your code might work on some processors, but not on others). These days, some * x86-64 processors apparently use only...
What you see in this code is a C99 Variable Length Array. A similar proposal almost made it to C++14, but didn't. So this code is not valid STANDARD C++, but your compiler may support it. AFAIK, C99 VLAs store their memory on the stack.
gc() will tell you the maximum memory usage. So if you start a new R session, run your code and then use gc() you should find what you need. Alternatives include the profiling functions Rprof and Rprofmem as referenced in @James comment above.
ios,memory,memory-management,xamarin,httpclient
Strange but yes, it is fixed in iOS8.3. NSURLCache was broken in iOS 8.x till iOS8.3. So it was not able to clear the cache. But as I have updated it to iOS8.3, it came down to 32KB block and consumes max 5-7MB.
java,memory,memory-management,out-of-memory
I tried to allocate memory by changing eclipse.ini setting to 2048 MB of ram as it was answered in this topic but still get the same errors after 3 hours or less. I hate to repeat myself(*), but in eclipse.ini you set up the memory for Eclipse, which has...
When arrays are declared in Java, they are stored as an array of references. You wouldn't run into this overhead cost when initializing an array of the Line class in C++ because your array will hold the objects, not merely their references.
TCM, Tightly-Coupled Memory is one (or multiple) small, dedicated memory region that as the name implies is very close to the CPU. The main benefit of it is, that the CPU can access the TCM every cycle. Contrary to the ordinary memory there is no cache involved which makes all...
xcode,osx,debugging,memory,objective-c-blocks
On the theController.completionHandler = nil; line you remove the last reference to the block, which causes the block to be deallocated. Then on the [theController release]; line, you access the block's captured copy of the theController variable, which is stored in the block. But you already deallocated the block, so...
java,c#,memory,memory-mapped-files
MemoryMappedFile mmf = MemoryMappedFile.CreateFromFile(fileName, FileMode.Read); using (MemoryMappedViewStream vs = mmf.CreateViewStream()) { // perform stream operations } A MemoryMappedViewStream is a thin veneer onto the memory....
The declaration of average has a limited lifetime in your code; it lives up to the end of the block. In other words, the way you declare average makes it available only inside the if/else block. I suggest splitting this up in two functions: one handles the allocation; the other...
c#,memory,ram,system.management
Simply increment a total in the loop, then format and display; UInt64 total = 0; foreach (ManagementObject ram in search.Get()) { total += (UInt64)ram.GetPropertyValue("Capacity"); } txtSystemInfo.Text += "\r\nRAM: " + total / 1073741824 + "GB"; ...
memory,memory-leaks,linux-kernel,linux-device-driver
It's really hard to track allocation and freeing memory in a kernel module, but you have some facilities still. Here are a couple tools and approaches to investigate memory leakage in kernel space. /proc/slabinfo (slabtop). It collects information about kernel structures. Not really about a module one. But it still...