For example if I run db2mtrk -a -v it gives something like
Memory for application 1234
Application Heap is of size 131072 bytes
Other Memory is of size 262144 bytes
Total: 393216 bytes
I can see the Application Heap size when I run db2pd -db foo -mempools from the physical size but I can't figure out where they get the Other memory total from.
I did a google search and couldn't come up with anything. Any ideas?
See the documentation for db2mtrk which states:
"The "Other Memory" reported is the memory associated with the usage
of operating the database management system."
and there are more details on the memory-allocation page showing how that is made up.
It's more convenient to use the following.
select
p.member
, coalesce(a.application_handle, p.application_handle) application_handle
, p.memory_pool_type
, p.edu_id
, p.memory_pool_used, p.memory_pool_used_hwm
, c.application_id, c.coord_member
from table(mon_get_memory_pool(null, current server, -2)) p
left join table(wlm_get_service_class_agents(null, null, null, -2)) a on a.dbpartitionnum=p.member and a.agent_tid=p.edu_id
left join table(mon_get_connection(null, -2)) c on c.application_handle=coalesce(a.application_handle, p.application_handle) and c.member=p.member
where 1234 in (a.application_handle, p.application_handle)
;
Related
Hi I'm trying to access the PCIe configuration space with MMIO method on a kernel base.
Before I drop my question, my platform is Windows 10, VirtualBox 6.0.10.
My virtual machine set as default except the following:
chipset choosed ICH9
Core number set to 4
Memory set to 1GB
Added IDE controller(no HD connected)
After boot, the printing shows that valid memory address are:0x0~0x9FC00 and 0x100000~0x3FEF0000 as displayed in following screen shot.
While type 1 is RAM, 2 is ROM or Reserved, 3 is ACPI Reclaim Memory and 4 is ACPI NVS Memory.
Furthermore I retrieved base address of the PCIe configuration memory map base address from MCFG as showed in the following screen shot.
It can be seen that:
The configuration space base is 0x3F000000 which overlap with the valid memory space.
The first 8 byte of 0x3F000000~0x3F000008 is all 0, which should be first 8 byte of bus:0, device:0, function:0.
So whether I should not use VirtualBox, or I should do some other operations to enable PCIe MMIO accessibility of configuration space?
Thanks so much!!
You've probably parsed the "MFCG ACPI table" incorrectly, or used the wrong (virtual?) address for the "MFCG ACPI table" and forgot to check signature and checksum.
The "Base_addr:" doesn't make sense, and the "Start_PCI_bus: 0, End_PCI_bus: 0" doesn't make sense either.
I am trying to debug a memory leak in a 64-bit C++ native application. The app leaks 1300 bytes 7-10 times a second - via plain malloc().
If I attach to the process with WinDBG and break into it every 60 seconds, !heap does not show any increase in memory allocated.
I did enable User Mode Stack trace database on the process:
gflags /i <process>.exe +ust
In WinDBG (with all the symbols successfully loaded), I'm using:
!heap -stat -h
But the output of the command never changes when I break in even though I can see the Private Bytes increase in Task Manager and a PerfMon trace.
I understand that when allocations are small they go to HeapAlloc(), when they're bigger they go to VirtualAlloc. Does !heap not work for HeapAlloc?
This post seems to imply that maybe using DebugDiag would work, but it still boils down to using WinDBG commands to process the dump. Tried to no avail.
This post also says that !heap command is broken for 64-bit apps. Could that be the case?
Is there an alternate procedure for diagnosing leaks in 64-bit apps?
!heap does not show any increase in memory allocated.
That may depend on which column you're looking at and how much memory the heap manager has allocated before.
E.g. it's possible that your application has a heap of 100 MB, of which just some blocks of 64kB are moving from the "reserved" column to the "committed" column. If the memory is committed right from the start, you won't see anything at all with a plain !heap command.
I did enable User Mode Stack trace database on the process
That will help you getting the allocation stack traces, but not affect the leak in general.
I understand that when allocations are small they go to HeapAlloc(), when they're bigger they go to VirtualAlloc.
Yes, for allocations > 512k.
Does !heap not work for HeapAlloc?
It should. And since C++ malloc() and new both use the Windows Heap manager, they should result in HeapAlloc() sooner or later.
The following code
#include <iostream>
#include <chrono>
#include <thread>
int main()
{
// https://stackoverflow.com/questions/53157722/windbg-diagnosing-leaks-in-64-bit-dumps-heap-not-showing-memory-growth
//
// I am trying to debug a memory leak in a 64-bit C++ native application.
// The app leaks 1300 bytes 7-10 times a second - via plain malloc().
for(int seconds=0; seconds < 60; seconds++)
{
for (int leakspersecond=0; leakspersecond<8;leakspersecond++)
{
if (malloc(1300)==nullptr)
{
std::cout << "Out of memory. That was unexpected in this simple demo." << std::endl;
}
std::this_thread::sleep_for(std::chrono::milliseconds(125));
}
}
}
compiled as 64 bit release build and run in WinDbg 10.0.15063.400 x64 shows
0:001> !heap -stat -h
Allocations statistics for
heap # 00000000000d0000
group-by: TOTSIZE max-display: 20
size #blocks total ( %) (percent of total busy bytes)
514 1a - 8408 (32.24)
521 c - 3d8c (15.03)
[...]
and later
0:001> !heap -stat -h
Allocations statistics for
heap # 00000000000d0000
group-by: TOTSIZE max-display: 20
size #blocks total ( %) (percent of total busy bytes)
514 30 - f3c0 (41.83)
521 18 - 7b18 (21.12)
even without +ust set.
It's 4.5M lines of code.
How do you then know that it leaks 1300 bytes via plain malloc()?
I'm trying to increase the memory limit for Intel HAXM. When I'm in the Intel Hardware Accelerated Execution Manager, on the screen where I choose to manually set the value, I get the error
Invalid input format, please input again! Note: The value must be
between 512 MB and 1.9 GB. Input content must be integer
When I enter the default value (1024 MB), it goes through, but I need to raise it, and I haven't found any other values that work (have tried 2000, 2048, 3072...) What's going on? Is this a definition of 'integer' I'm unfamiliar with?
I had the same problem (I'm running on windows) my problem was the emulator "closed" but the process didn't quit so it was still sitting there not allowing me start another emulator because I "exceed" my Haxm memory limit. So I opened up my Task Manager and looked for the emulator in the processes and sure enough the process was still running. ( it was easy to spot because it was set the amount of ram that I gave the emulator ) so I force quit that process and the emulator fired up again and I went on about my day. Hope this helps!
I have 8 managed gc heaps reported by !eeheap -gc:
0:000> !eeheap -gc
Number of GC Heaps: 8
------------------------------
Heap 0 (00000000009a2c50)
generation 0 starts at 0x00000000d92e3aa0
generation 1 starts at 0x00000000d8cdb128
generation 2 starts at 0x000000007fff1000
ephemeral segment allocation context: none
segment begin allocated size
000000007fff0000 000000007fff1000 00000000d93edab8 0x593fcab8(1497352888)
Large object heap starts at 0x000000047fff1000
segment begin allocated size
000000047fff0000 000000047fff1000 0000000487fabf00 0x7fbaf00(133934848)
00000004e6400000 00000004e6401000 00000004ee3af2f8 0x7fae2f8(133882616)
000000050e400000 000000050e401000 00000005152f8578 0x6ef7578(116356472)
0000000572400000 0000000572401000 00000005756e8ad8 0x32e7ad8(53377752)
Heap Size: Size: 0x73544d00 (1934904576) bytes.
------------------------------
Heap 1 (00000000009ad690)
generation 0 starts at 0x00000001609a9cc8
generation 1 starts at 0x000000016072f780
generation 2 starts at 0x00000000ffff1000
ephemeral segment allocation context: none
segment begin allocated size
00000000ffff0000 00000000ffff1000 0000000161bf8f50 0x61c07f50(1640005456)
Large object heap starts at 0x0000000487ff1000
segment begin allocated size
0000000487ff0000 0000000487ff1000 000000048ffea910 0x7ff9910(134191376)
0000000044b50000 0000000044b51000 000000004cb44978 0x7ff3978(134166904)
000000051e400000 000000051e401000 000000052575aae0 0x7359ae0(120953568)
000000057a400000 000000057a401000 000000057c2e8610 0x1ee7610(32405008)
Heap Size: Size: 0x7ae362c8 (2061722312) bytes.
...
I would like to run the !dumpheap -dead command on the gen 2 and LOH only, however, I am a bit confused as to:
The command clearly says where the gen 2 starts, but it is unclear to me where does it end. For example, for Heap 0 I figure I give -start 0x000000007fff1000, but what goes into -end ? Is it the start of gen 1?
I have 8 heaps, so I guess I have to run the !dumpheap -dead 8 times for gen 2. For LOH, which seems to span multiple fragments, the number of times is even higher. Is there a way to automate the process of dumping all these dead objects across all the LOHs and gen 2s?
I have C program running on a AVR32 microcontroller (UC3C0512C).
Issuing the avr32-size -A PROGRAM.elf command generates the following output:
PROGRAM.elf :
section size addr
.reset 8200 2147483648
.rela.got 0 2147491848
.text 99512 2147491848
.exception 512 2147591680
.rodata 5072 2147592192
.dalign 4 4
.data 7036 8
.balign 4 7044
.bss 5856 7048
.heap 48536 12904
.comment 48 0
.debug_aranges 8672 0
.debug_pubnames 14476 0
.debug_info 311236 0
.debug_abbrev 49205 0
.debug_line 208324 0
.debug_frame 23380 0
.debug_str 43961 0
.debug_loc 63619 0
.debug_macinfo 94469328 0
.stack 4096 61440
.data_hram0 512 2684354560
.debug_ranges 8368 0
Total 95379957
Can someone explain how to interpret these values?
How can I calculate the flash and ram usage based on this list?
Update 1:
Without the -A flag, I am getting the following:
text data bss dec hex filename
113296 7548 58496 179340 2bc8c PROGRAM.elf
Update 2:
I'm not using dynamic memory allocation, so according the avr-libc user-manual, the free RAM space should be simply: stackpointer minus __heap_start.
In this case: 61440 - 12904 = 48536 byte free RAM space.
Can someone confirm that?
(There is a mismatch in the two outputs in your question. The bss number is wildly different.)
If you don't use malloc, and don't count the stack, then yes, the RAM usage is the data plus the bss (plus some alignment spacing). The data are the variables that are set in a declaration, and the bss are the variables that are not. The C runtime will probably initialize them to 0, but it doesn't have to.
The flash usage will be the text and the data. That is, the flash will include the program instructions and C runtime, but also the values that need to get copied into RAM on startup to initialize those variables. This data is generally tacked onto the end of the program instructions.
Re: update 2
RAM holds global variables, the heap, and then the stack in that order.
The global variables can be initialized in the program, or not. The .data section is stored in flash, and the C runtime copies these values into the beginning of RAM where the corresponding variables live before your code runs. The .bss section of global variables needs space in RAM to hold the values, but they aren't necessarily initialized. The C runtime that comes with avr-gcc does actually initialize these to 0. The point it that your don't need to store an array of 0s to copy over, as you do with the .data section.
You are not using heap, but dynamically allocated memory is obtained from the addresses between heap_start and heap_end.
But the stack is not limited. Yes, the stack-pointer is initialized at startup, but it changes as your program runs, and can move well into the heap or even into the global variables (stack overflow). The stack pointer moves whenever a function is called, or local variables within a function are used. For example, a large array declared inside a function will go on the stack.
So in answer to your question, there is no RAM that is guaranteed to remain free.
I think you should remove the -A (all) flag, since that gives you the more low-level list you're showing.
The default output is easier to parse, and seems to directly state the values you're after.
Note: I didn't try this, not a system with an AVR toolchain installed.
I guess that in your linker script you have RAM at 0, and Flash at 0x80000000, so all things that need to go to RAM are at addresses 0+ (.stack is the last at 61440 (spanning next 4k)). So you would need a bit more that 64k of RAM. Everything else you have is flash.
That is provided that your linker script is correct.
Also see unwind's comment.
These values are the assembly language sections of the compiled C code. See the docs for the details. This article is also helpful.
The section titled .text represents the instruction section, i.e. the assembly instructions. The .data section represents the size of the variables (ints, arrays, etc.). The size column has the significant info, and it has the size of each section in bytes. The .stack and .heap represent the memory allocated in preparation for the execution of the program to set up the virtual memory.
You can try
avr-nm --print-size --radix d --demangle x.elf
to get the sizes in decimal notation.
Then you can copy & paste into a spreadsheet, filter, sort by the sections, and sum it up.