What is dirty personal memory?

I am developing an application on a 64-bit Linux system. As I could see, there is too much dirty heap memory in my application. Speaking of a heap of memory, what does dirty mean? What makes it arise and what can be done to prevent its occurrence?

EDIT

I’ll better explain what operations my application performs.

My application runs in two threads: the first thread sends jobs to the queue, which are then executed in another thread. Thus, the first thread selects the pages that should be queued, and the second thread decompresses them, performs its tasks, and frees them. All these operations are performed in a thread-safe manner.

So, I took a test for this thing, putting a queue in 100000000 tasks and completing them all. Up to a point, memory usage increases. Then, when the priority process ends and only the remaining remains, the memory load does not inexplicably decrease. Finally, when all tasks are deleted and executed, all this memory is freed. So the memory leak seems to occur during the dequeuing process, because when it ends, all the memory is freed, but I did not find anything wrong in my code.

I know that it would be better if I posted my code here, but it is too large. But, from what I added, can anyone suggest what could be causing this?

+6
source share
2 answers

Speaking that the memory does not decrease even after the release of some fragments, it is better to use mmap in anonymous mode as follows:

 mmap(NULL, chunck_size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); 

which does not display the file descriptor and returns a pointer to a piece of memory that immediately returns to the OS when it is deleted. However, mmap requires a system call, which is slower than malloc. Therefore, you should use mmap to highlight large pages.

+3
source

I found this

Inact_dirty: Dirty means "may need to write to disk or swap". takes more liberation work. Examples are files that have not yet been written. They too soon are not written to memory for I / O. For example, if you are writing magazines, it might be better to wait while you have a finished journal before sending it to disk.

Taken from here: http://www.redhat.com/advice/tips/meminfo.html

I think this looks like a dirty bit on I / O buffers? By this, I mean a bit that indicates that this buffer should be written to disk because it was modified (on linux).

Here you have a similar question: https://unix.stackexchange.com/questions/33381/getting-information-about-a-process-memory-usage-from-proc-pid-smaps

+3
source

Source: https://habr.com/ru/post/945886/


All Articles