I have an app in which I suspect a memory leak. Not only in the heap, but it seems to me the whole working set is growing for each request that is made to my app. I am trying to debug it according to these instructions but I am having a hard time interpreting what I see. I am using the dotnet-dump tool to analyze a dump.
All in all I have 618 DocumentClient instances if I interpret it correctly. Of course that will add up to a lot of data in strings, byte arrays etc.
Statistics:
MT Count TotalSize Class Name
00007f853c355110 618 187872 Microsoft.Azure.Cosmos.DocumentClient
Here is a snippet of a single reference taken from the method table of the document client. See the pastebin for full reference. It continues for 1200+ lines with mostly TimerQueueTimer references.
00007F85AF2F10D8 (strong handle)
-> 00007F84C80FBAD8 System.Object[]
-> 00007F84C80FBB00 System.Threading.ThreadLocal`1+LinkedSlotVolatile[[System.Collections.Concurrent.ConcurrentBag`1+WorkStealingQueue[[System.IDisposable, System.Private.CoreLib]], System.Collections.Concurrent]][]
-> 00007F84C80FBB40 System.Threading.ThreadLocal`1+LinkedSlot[[System.Collections.Concurrent.ConcurrentBag`1+WorkStealingQueue[[System.IDisposable, System.Private.CoreLib]], System.Collections.Concurrent]]
-> 00007F84C80FBB70 System.Collections.Concurrent.ConcurrentBag`1+WorkStealingQueue[[System.IDisposable, System.Private.CoreLib]]
-> 00007F84C80FBBB0 System.IDisposable[]
-> 00007F84C80FBA90 System.Diagnostics.DiagnosticListener+DiagnosticSubscription
-> 00007F84C80FAF30 Microsoft.ApplicationInsights.AspNetCore.DiagnosticListeners.HostingDiagnosticListener
-> 00007F84C80EB450 Microsoft.ApplicationInsights.Extensibility.TelemetryConfiguration
-> 00007F84C80D5688 Microsoft.ApplicationInsights.Extensibility.Implementation.ApplicationId.ApplicationInsightsApplicationIdProvider
-> 00007F84C80D5A60 Microsoft.ApplicationInsights.Extensibility.Implementation.ApplicationId.ProfileServiceWrapper
-> 00007F84C80D5A88 System.Net.Http.HttpClient
-> 00007F84C80D5AD0 System.Net.Http.HttpClientHandler
-> 00007F84C80D5B00 System.Net.Http.SocketsHttpHandler
-> 00007F84D80D1018 System.Net.Http.RedirectHandler
-> 00007F84D80D1000 System.Net.Http.HttpConnectionHandler
-> 00007F84D80D0D38 System.Net.Http.HttpConnectionPoolManager
-> 00007F84D80D0F70 System.Threading.Timer
-> 00007F84D80D0FE8 System.Threading.TimerHolder
-> 00007F84D80D0F88 System.Threading.TimerQueueTimer
-> 00007F84C80533A0 System.Threading.TimerQueue
-> 00007F84D910F3C0 System.Threading.TimerQueueTimer
-> 00007F84D910EE58 System.Threading.TimerQueueTimer
-> 00007F84D910A680 System.Threading.TimerQueueTimer
https://pastebin.com/V8CNQjR7
Do I have an Application Insights or Cosmos memory leak? Why are there so many TimerQueueTimer references?
await Task.Delay create new TimerQueueTimer on every call.
Lots of TimerQueueTimer is sign of someone is using await Task.Delay() in a loop, instead of using simple new Timer().
-> Microsoft.Azure.Cosmos.Routing.GlobalEndpointManager+<StartRefreshLocationTimer>d__25
-> Microsoft.Azure.Cosmos.Routing.GlobalEndpointManager
Looks like GlobalEndpointManager of Microsoft.Azure.Cosmos uses await Task.Delay every time exception is thrown in StartRefreshLocationTimer method of GlobalEndpointManager.cs class
You can try few things here:
1) Check which exception is thrown and how to avoid it.
My guess this should help log exception:
DefaultTrace.TraceSource.Listeners.Add(new System.Diagnostics.ConsoleTraceListener())
(check example)
2) make sure ShouldRefreshEndpoints returns false, if it's ok for your app :)
I need to disable the Accurancy check only on every execution plan configured.
The others check (Performance, Availability Errors, Execution Errors) must be active.
Could anyone help me?
Regards,
Ema
Below my solution
Guide: https://community.microfocus.com/borland/tm_art/w/knowledge_base/22848/classifying-tm-art-workbench-script-runtime-error-as-availability-or-accuracy-error-in-tm-art-central
Steps:
open file .ltz with Silk Performer
Settings -> Active Profile -> Replay -> Simulation -> Errors tab
Click the Add... button.
Select a module and a severity and the list of predefined error codes will appear in the table.
For example, select "BMC TM ART - HTTP" as module and "error" as Severity. In the list of error codes, you will find the code "500" and its error description "internal server error". Below is a screenshot of some error codes for the WinSock module.
Select the new severity
Save and reload file .ltz
Using Selenium IDE Firefox plugin, I want to take automated screenshots. The test script contains these steps
Command Target Value
open /?gfe_rd=cr&ei=GNCWU-6BCujV8geh_4C4Bg&gws_rd=ssl
click id=gbqfq
type id=gbqfq software testing
click id=gbqfb
captureEntirePageScreenshotAndWait F:\Screenshots\
The log shown this error:-
[error] Unexpected Exception: [Exception... "Component returned failure code: 0x80520015 (NS_ERROR_FILE_ACCESS_DENIED) [nsIFileOutputStream.init]" nsresult: "0x80520015 (NS_ERROR_FILE_ACCESS_DENIED)" location: "JS frame :: chrome://selenium-ide/content/selenium-core/scripts/selenium-api.js :: <TOP_LEVEL> :: line 2986" data: no]. toString -> function toString() { [native code] }, message -> Component returned failure code: 0x80520015 (NS_ERROR_FILE_ACCESS_DENIED) [nsIFileOutputStream.init], result -> 2152857621, name -> NS_ERROR_FILE_ACCESS_DENIED, filename -> chrome://selenium-ide/content/selenium-core/scripts/selenium-api.js, lineNumber -> 2986, columnNumber -> 0, inner -> null, data -> null, location -> JS frame :: chrome://selenium-ide/content/selenium-core/scripts/selenium-api.js :: <TOP_LEVEL> :: line 2986
please resolve this error
There is a Screenshot on Failure plugin. It grabs a screenshot of the HTML at the point of failure as per it's name. Here is the link:
https://addons.mozilla.org/en-US/firefox/addon/screenshot-on-fail-selenium/
This plugin integrates directly with Selenium so you can turn it on or off through the UI itself. To install it, open the link with a FIREFOX browser and click the "ADD TO FIREFOX" link. (For those not familiar with the Selenium IDE, it only plugs into Firefox.)
Once installed properly you will see a Screenshot on Fail icon next to the "FAST - SLOW" slider. Toggling this button on turns on the feature, toggling it off means that snapshots won't be taken. By default it is off when the IDE is launched. The tiny down-arrow next to it allows you to view the screen shot / failure report(s).
I'm trying to do some testing while working on GUIs, but I am running into trouble having console access at the same time.
Rebol 3
>> view/new [button]
** Script error: view has no refinement called new
>> help view
USAGE:
VIEW spec /options opts /modal /no-wait /across /as-is /maximized /minimized /on-error error-handler
DESCRIPTION:
Displays a window view from a layout block, face (layout), or low level graphics object (gob).
VIEW is a function value.
ARGUMENTS:
spec -- Layout block, face object, or gob type (block! object! gob!)
REFINEMENTS:
/options
opts -- Optional features, in name: value format (block!)
/modal -- Display a modal window (pop-up)
/no-wait -- Return immediately - do not wait
/across -- Use horizontal layout-mode for top layout (rather than vertical)
/as-is -- Use GOB exactly as passed - do not add a parent gob
/maximized -- Open window in maximized state
/minimized -- Open window in minimized state
/on-error
error-handler -- specify global error handler (block!)
Looking at the help, I tried
view/no-wait
and this gives console access, but the REB-GUI window locks up. What is going on with this? Is there a way to be able to access commands through the console while playing with the GUI?
There isn't a way to have both console access and the gui concurrently.
But you could use an area face to enter commands and a button to evaluate those commands in your GUI.
I'm basically following the tutorial on this site Learn you some Erlang:Designing a concurrent application and I tried to run the code below with the following commands and got an error on line 48. I did turn off my firewall just in case that was the problem but no luck. I'm on windows xp SP3.
9> c(event).
{ok,event}
10> f().
ok
11> event:start("Event",0).
=ERROR REPORT==== 9-Feb-2013::15:05:07 ===
Error in process <0.61.0> with exit value: {function_clause,[{event,time_to_go,[0],[{file,"event.erl"},{line,48}]},{event,init,3,[{file,"event.erl"},{line,31}]}]}
<0.61.0>
12>
-module(event).
-export([start/2, start_link/2, cancel/1]).
-export([init/3, loop/1]).
-record(state, {server,
name="",
to_go=0}).
%%% Public interface
start(EventName, DateTime) ->
spawn(?MODULE, init, [self(), EventName, DateTime]).
start_link(EventName, DateTime) ->
spawn_link(?MODULE, init, [self(), EventName, DateTime]).
cancel(Pid) ->
%% Monitor in case the process is already dead
Ref = erlang:monitor(process, Pid),
Pid ! {self(), Ref, cancel},
receive
{Ref, ok} ->
erlang:demonitor(Ref, [flush]),
ok;
{'DOWN', Ref, process, Pid, _Reason} ->
ok
end.
%%% Event's innards
init(Server, EventName, DateTime) ->
loop(#state{server=Server,
name=EventName,
to_go=time_to_go(DateTime)}).
%% Loop uses a list for times in order to go around the ~49 days limit
%% on timeouts.
loop(S = #state{server=Server, to_go=[T|Next]}) ->
receive
{Server, Ref, cancel} ->
Server ! {Ref, ok}
after T*1000 ->
if Next =:= [] ->
Server ! {done, S#state.name};
Next =/= [] ->
loop(S#state{to_go=Next})
end
end.
%%% private functions
time_to_go(TimeOut={{_,_,_}, {_,_,_}}) ->
Now = calendar:local_time(),
ToGo = calendar:datetime_to_gregorian_seconds(TimeOut) -
calendar:datetime_to_gregorian_seconds(Now),
Secs = if ToGo > 0 -> ToGo;
ToGo =< 0 -> 0
end,
normalize(Secs).
%% Because Erlang is limited to about 49 days (49*24*60*60*1000) in
%% milliseconds, the following function is used
normalize(N) ->
Limit = 49*24*60*60,
[N rem Limit | lists:duplicate(N div Limit, Limit)].
It's running purely locally on your machine so the firewall will not affect it.
The problem is the second argument you gave when you started it event:start("Event",0).
The error reason:
{function_clause,[{event,time_to_go,[0],[{file,"event.erl"},{line,48}]},{event,init,3,[{file,"event.erl"},{line,31}]}]}
says that it is a function_clause error which means that there was no clause in the function definition which matched the arguments. It also tells you that it was the function event:time_to_go/1 on line 48 which failed and that it was called with the argument 0.
It you look at the function time_to_go/ you will see that it expects its argument to be a tuple of 2 elements where each element is a tuple of 3 elements:
time_to_go(TimeOut={{_,_,_}, {_,_,_}}) ->
The structure of this argument is {{Year,Month,Day},{Hour,Minute,Second}}. If you follow this argument backwards you that time_to_go/ is called from init/3 where the argument to time_to_go/1, DateTime, is the 3rd argument to init/3. Almost there now. Now init/3 is the function which the process spawned in start/2 (and start_link/2) and the 3rd argument toinit/3is the second argument tostart/2`.
So when you call event:start("Event",0). it is the 0 here which is passed into the call time_to_go/1 function in the new peocess. And the format is wrong. You should be calling it with something like event:start("Event", {{2013,3,24},{17,53,62}}).
To add background to rvirding's answer, you get the error because the
example works up until the final code snippet as far
as I know. The normalize function is used first, which deals with the
problem. Then the paragraph right after the example in the question
above, the text says:
And it works! The last thing annoying with the event module is that we
have to input the time left in seconds. It would be much better if we
could use a standard format such as Erlang's datetime ({{Year, Month,
Day}, {Hour, Minute, Second}}). Just add the following function that
will calculate the difference between the current time on your
computer and the delay you inserted:
The next snippet introduces the code bit that takes only a date/time and
changes it to the final time left.
I could not easily link to all transitional versions of the file, which
is why trying the linked file directly with the example doesn't work
super easily in this case. If the code is followed step by step, snippet
by snippet, everything should work fine. Sorry for the confusion.