Any idea if this profiler still works with recent versions of Emscripten ?

On Tuesday, November 12, 2013 at 4:28:35 PM UTC, jj wrote:
>
> Some updates to the memory profiler: (download from 
> https://dl.dropboxusercontent.com/u/40949268/emcc/memoryprofiler/memoryprofiler.js
>  
> )
>
>  - The profiler will now also print the amount of memory consumed by audio 
> clips you have loaded to the OpenAL audio backend, which are stored outside 
> the Emscripten HEAP.
>  - Added a color legend, thanks Floh for the suggestion :)
>  - Added a mechanism for tracking currently allocated pointers by 
> callstack. You can use this to detect running memory leaks or taking a 
> delta of allocations between two times as follows:
>      - tick the checkbox "Print allocation statistics by callstack to html 
> log" at time A.
>      - run the page for a while.
>      - untick the same checkbox at time B.
>      - the log at the end of the page will show all pointers that were 
> allocated between times A to B and are still alive, grouped by callstack.
>
> See a running demo at 
> https://dl.dropboxusercontent.com/u/40949268/emcc/memoryprofiler/Geometry_d.html
>  
> , although that might not be the best example, since it does very few 
> allocations and does not leak.
>
> Known limitations:
>   - If you used a custom <script> tag to preload the VFS, the profiler 
> will show the space taken up by the VFS in green, not orange, i.e. the 
> profiler will not understand that it was allocated by the VFS.
>   - Detailed memory tracking is not available if compiled under asm.js. 
> This is because it is not possible to inject custom replacements to 
> malloc() and free() after they were compiled to asm.js.
>   - If you compiled with the --no-heap-copy linker flag, the VFS will not 
> be seen by the profiler at all. Use e.g. Firefox about:memory tab to see 
> the whole browser memory consumption.
>   - Call stack demangling with the allocated pointer logging gets the 
> symbols confused at times, only partially demanling some of the names.
>
> Hope you find some use for it,
>    Jukka
>
>
> 2013/10/7 wolfviking0 <[email protected] <javascript:>>
>
>> Hi JJ,
>>
>> Your last version is working well for me on WebKit.
>>
>> Thanks.
>>
>> PS: May be just one suggestion, add the color for the legend will be nice 
>> (not just text description).
>>
>>
>>
>> <https://lh5.googleusercontent.com/-5743sFCtIgo/UlJcj_xnmPI/AAAAAAAA-wM/OguKr7235FA/s1600/Capture+d%E2%80%99e%CC%81cran+2013-10-07+a%CC%80+08.57.49.png>
>>
>>
>>
>> Le jeudi 26 septembre 2013 23:28:22 UTC+2, jj a écrit :
>>
>>> Hi,
>>>
>>> I got caught by the season flu, and I thought I'd do something fun for a 
>>> change, so here goes.
>>>
>>> Memoryprofiler.js is a tool that integrates to Emscripten-built .html 
>>> applications, and it tracks the various Emscripten memory area uses, and 
>>> draws a graph of memory fragmentation in the Emscripten HEAP.
>>>
>>> It hooks into the malloc(), free() and Runtime.stackAlloc() functions of 
>>> the Emscripten runtime, and captures the memory usage as it happens.
>>>
>>> See a live demo here https://dl.dropboxusercontent.com/u/
>>> 40949268/emcc/memoryprofiler/Geometry_d.html
>>>
>>> A quick glossary of the related terms if you are not yet familiar with 
>>> them:
>>>
>>> HEAP: This is the single large memory blob that the Emscripten 
>>> application allocates at startup, and is all the memory that the Emscripten 
>>> application ever sees. The STATIC, STACK and DYNAMIC memory areas are 
>>> allocated inside this chunk.
>>>
>>> STATIC: This memory area contains constants and globals allocated at 
>>> application startup time. Its size never changes at runtime. The STATIC 
>>> memory area is in the lowest part of the Emscripten HEAP.
>>>
>>> STACK: This is the application function call stack. Note that unlike the 
>>> X86 stack that grows downwards, the Emscripten stack grows up. The profiler 
>>> tracks how much space is used in the stack during the time stack and heap 
>>> allocations occur, but note that it is only approximate - not all stack 
>>> usage can be captured.
>>>
>>> DYNAMIC: The memory area for dynamic heap allocations. This is the pool 
>>> where memory is taken from when operator new or malloc is called.
>>>
>>> As is readily visible in the map that gets graphed, the memory layout 
>>> inside HEAP looks like
>>>
>>> (address 0) [ STATIC | STACK | DYNAMIC | empty ] (top of HEAP)
>>>
>>> The empty space between the top of the DYNAMIC area and the end of HEAP 
>>> is unused, but fully reserved for the DYNAMIC area to grow into (via a page 
>>> allocation operation from a function _sbrk). The total amount of memory the 
>>> application can allocate is the sum of the empty area
>>> plus the amount of free memory in DYNAMIC (minus fragmentation of the 
>>> HEAP in DYNAMIC).
>>>
>>> To embed memoryprofiler.js to your own builds:
>>>
>>> 1. Download https://dl.dropboxusercontent.com/u/
>>> 40949268/emcc/memoryprofiler/memoryprofiler.js and place it next to 
>>> your built Emscripten .html file.
>>> 2. Add a line "<script src='memoryprofiler.js'></script>" to your 
>>> application .html file to link memoryprofiler.js to it.
>>> 3. In the Module properties of your application .html file, add a preRun 
>>> call to memoryprofiler initialization function 
>>> 'memoryprofiler_add_hooks()'. That is, replace the default line in Module 
>>> that reads
>>>
>>> preRun: []
>>>
>>> with
>>>
>>> preRun: [memoryprofiler_add_hooks]
>>>
>>> and reopen the page. That's it!
>>>
>>> To make steps 2. and 3. persist between builds, you can add the <script> 
>>> tag and the preRun dependency to your custom shell file (copy the provided 
>>> shell.html in emscripten source directory to your project and make the 
>>> changes there), and use --shell-file my_shell_with_profiler.html at 
>>> Emscripten link time to use that shell instead.
>>>
>>> Configuration:
>>>
>>> There are a few items you can configure in the profiler. Configuration 
>>> occurs by directly editing the file memoryprofiler.js. See the variables
>>>
>>> MEMORYPROFILER_DETAILED_HEAP_USAGE MEMORYPROFILER_TRACK_CALLSTACK_MIN_SIZE 
>>> MEMORYPROFILER_HOOK_STACKALLOC
>>> MEMORYPROFILER_UI_UPDATE_INTERVAL 
>>>
>>> and their documentation in top of the file itself.
>>>
>>> Hope it works!
>>>    Jukka
>>>
>>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "emscripten-discuss" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to [email protected] <javascript:>.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"emscripten-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to