Menu
  • HOME
  • TAGS

Measure memory usage of a certain Linux driver module

Tag: memory,memory-leaks,linux-kernel,linux-device-driver

I want to check whether the kernel driver module which I just finished has a memory leak problem. But I don't know how to do it in kernel space. Dynamic memory allocation is very hard to handle I think. Anyone has the experience in debugging such memory problem in kernel space? Or, which tool can I use to measure the dynamic memory usage of a specific kernel module?

Best How To :

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.

  1. /proc/slabinfo (slabtop). It collects information about kernel structures. Not really about a module one. But it still might be very helpful.

  2. Kmem and ftrace. Just links:

https://www.kernel.org/doc/Documentation/trace/events-kmem.txt

http://elinux.org/Kernel_dynamic_memory_analysis

Trap each kmalloc, kfree, etc. event and produce relevant information with them.(c)

  1. /proc/modules (lsmod). Nothing special except information how much memory a module uses when it's loaded. In fact it's just the size of a module.

Wpf RadDocking memory leak

c#,wpf,memory-leaks,telerik

You need to call RadPane's RemoveFromParent() method for it to be garbage collected. Please check out these links: http://www.telerik.com/forums/radpanegroup-memory-leak http://www.telerik.com/forums/radpane-not-garbage-collected-when-closed...

SetProcessWorkingSetSize does not work in compiling 64bit

delphi,memory

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...

Memory usage in R during running a code

r,memory

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.

Memory Issue for Array Conversion

python,memory,numpy

You probably don't have to do the conversion. If you are performing some calculation with your bool array and another float array, the conversion will be handled during the operation: import numpy as np y = np.array([False, True, True, False], dtype=bool) x = np.array([2.5, 3.14, 2.7, 8.9], dtype=float) z =...

Android: int array set null but still in memory after GC

android,memory-leaks,bitmap

You have declared int[] pix to be an instance variable. So when an object of this class will be created a copy of pix variable will be created in memory and it will remain in memory till the object lasts. In your case you can declare int[] pix to be...

Memory error in c++ (armadillo)

c++,memory,armadillo

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...

Retain cycle in Swift when Object A has Object B as a property and Object B has an array property that contains Object A?

ios,swift,memory-management,memory-leaks,retain-cycle

Generally speaking, with manual reference counting and automatic reference counting, reference ilands will leak. Reference cycle can be composed by more than just 2 objects. That said I encourage you to test some code in a playground since the example in your question has some syntax and language errors. The...

C++11 Allocation Requirement on Strings

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...

Getting many memory errors when try to run it for few days in my web crawler [on hold]

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...

clEnqueueNDRangeKernel fills up entire memory

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....

Unable to increase PHP Memory Limit

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...

In Spark, what is left in the memory after a Job is done?

memory,apache-spark,rdd

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...

Changing Django code logs me out of application

python,django,memory

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...

cuda-memcheck fails to detect memory leak in an R package

r,memory-leaks,cuda,valgrind

This is not valid CUDA code: extern "C" void someCUDAcode() { int a; CUDA_CALL(cudaMalloc((void**) &a, sizeof(int))); mykernel<<<1, 1>>>(1); // CUDA_CALL(cudaFree(&a)); } When we want to do a cudaMalloc operation, we use pointers in C, not ordinary variables, like this: int *a; CUDA_CALL(cudaMalloc((void**) &a, sizeof(int))); When we want to free a...

sort runs out of memory

linux,sorting,memory,ram

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.

Does the dart VM impose restrictions on the stack memory size of a native extension?

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...

System.Management, Management Object Searcher, and RAM

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"; ...

why does “[[UIDevice currentDevice] identifierForVendor]”cause memory leak?

ios,memory-leaks

It isn't leaking memory as such UIDevice currentDevice returns a singleton - that is, each subsequent call to currentDevice will return a reference to the same object instance. This singleton instance is allocated on the first call to currentDevice and this object will remain allocated until your app exits. This...

Search for file in archive and load it into memory

c++,memory,archive,ram

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...

what's ARM TCM memory

memory,arm

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...

Is it safe to read and write on an array of 32 bit data byte by byte?

c,memory,memory-alignment

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...

I am getting error in this code as “invalid indirection”

c,memory,dynamic,indirection

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...

1MiB = 1024KiB = 2^10. Nonetheless, why not use just 1000 byte instead 1024 to calculate size? [closed]

memory,binary,size,cpu

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....

Creating an instance from assembly throws a memory leak

.net,reflection,memory-leaks

After 2 days searching on the net i have been able to resolve the error. This is the solution for anyone on my situation. The classes you want to load by reflection have to implement the IDisposable interface. These classes have to override the Dispose method. In this method, simply...

Memory leaks and jQuery plugin

javascript,jquery,memory-leaks

Looks fine to me. Your variable $bar is declared within the function scope so it won't be accessible outside of it. $bar = null; - is enough to clear the reference to your element. ...

Which channel type uses the least amount of memory in Go?

memory,go,resources,channel,internals

Looking at the latest implementation of the channel, it's not a trivial structure: type hchan struct { qcount uint // total data in the queue dataqsiz uint // size of the circular queue buf unsafe.Pointer // points to an array of dataqsiz elements elemsize uint16 closed uint32 elemtype *_type //...

Good approach to clean application data programmmatically in Android

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.

Program Runs Fine for Hours and Eventually Seg Faults with Memory Address 0x10 [closed]

c++,c,memory,arm

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...

The range of virtual memory address in userspace

c,linux,memory

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...

How to find the dll which causes a memory leak and not directly referenced by application

c#,wpf,dll,memory-leaks,msvcrt

The answer was not easy to find. I had tried each DLL that I suspected one by one. The leak was an undeleted array in a C++/CLI wrapper class. Since it is a managed dll, I think, the native "new" calls are traced through msvcr110.dll, and ANTS shows leak in...

Scrapy Memory Error (too many requests) Python 2.7

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...

Java - allocation in enhanced for loop

java,for-loop,memory

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...

How to fix D “memory leaks”

memory-leaks,d

Are the strings in the returned data still pointing inside the original text file? Array slicing operations in D do not make a copy of the data - instead, they just store a pointer and length. This also applies to splitLines, split, and possibly to doSomeOtherCalculation. This means that as...

fread(), solaris to unix portability and use of uninitialised values

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...

Memory javascript dictionary

javascript,memory

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...

Converting collection to array with no extra memory

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...

function to get 2d-arrays from stack and heap

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...

What diagnostic tools are available for Node.js applications?

node.js,memory-leaks,diagnostics

Yes, IDDE is a powerful tool not only for memory leak detection, but for a wide variety of problem determination of Node.js misbehaviors, including crashes and hangs. Here is the link for overview, installation, and what is new information: https://www.ibm.com/developerworks/java/jdk/tools/idde I would start with nodeoverview command. Note that every command...

Linux “free -m”: Total, used and free memory values don't add up [closed]

linux,memory

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...

Looking into dynamic variables created using pointers?

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...

Detemine memory used by Hazelcast cache

java,caching,memory,hazelcast

Either you buy the Hazelcast Managementcenter or you can gather the information using JMX and aggregate them on your own. Please find the JMX documentation here: http://docs.hazelcast.org/docs/3.5/manual/html-single/hazelcast-documentation.html#jmx-api-per-node

Memory management in game development?

android,memory

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/...

Does Python copy references to objects when slicing a list?

python,list,memory,copy,slice

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...

Heroku RAM not increasing with upgraded dynos

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.

AvailableVirtualMemory on IIS and Console application

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...

In 64bit R, what should my memory.limit() be set to?

r,memory,64bit

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...

How to prevent memory leak in JTextPane.setCaretPosition(int)?

java,swing,memory-leaks,jtextpane,caret

The reason for this is that you are running the for loop in the event dispatch thread (see Event Dispatch Thread). This is the thread in which all user interface interactions happens. If you are running a long task, then you should run it in a different thread, so that...

Watch values of variables in KDevelop

c++,arrays,memory,kdevelop

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...

Assigning memory dynamically or on the stack based on a condition (if statement)

c,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...

How can I measure the memory occupancy of Python MPI or multiprocessing program?

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...