My .NET Core 2 API running on App Service has an ever growing memory-usage. Going up to the point the app service crashes and we need to restart it. Last time I made a memory dump in Kudu and opened it in VS2017.
I'm a rookie in analyzing this file, but sorting on the Inclusive Size, almost all logging objects claim a lot of RAM. See attached print-screen:
I think that somehow these resources are not disposed. A sample of my Autofac-container configuration is below:
var assemblies = new Assembly[]
{
Assembly.Load("....")
};
builder.RegisterAssemblyTypes(assemblies)
.Where(t => !t.Name.EndsWith("CachedRepository") && !t.Name.EndsWith("DbCachedRepository"))
.AsImplementedInterfaces()
.InstancePerBackgroundJob() // Dispose after Hangfire job
.InstancePerLifetimeScope(); // Dispose after http request
How can I control the disposal of the Logger objects?
Many thanks in advance.
Problem was solved by reading the link provided by David Fowl. It's a github issue with a kown Azure Logging problem. See https://github.com/aspnet/Logging/issues/821.
After disabling the blob logger, everything was solved.
Related
I have been checking a lot of threads on this topic , and can't seem to find a clear answer to this .
Question :
Do service workers check imported scripts for byte size difference, and trigger update of SW if there is difference.
In GitHub issues I went through :
Add web SDK API for service worker to be updated manually
Consider relying on eTags (or other headers) for service worker dependencies to check for updates
And also followed up with these :
Jake Archibald's Service worker meeting notes
Service worker: importScripts never updates scripts
Most of the articles are from 2016/17 and they are saying this should be implemented. On GitHub theres even a mention that work on this has started, but nothing more, no clear status on this or maybe I'm just missing it ?
Any info on this would be helpful.
According to this, starting in version 68, chrome will ignore HTTP cache when requesting updates to the service worker script. Requests for importScripts will still go via the HTTP cache. But this is just the default—a new registration option, updateViaCache is available that offers control over this behavior.
Example of updateViaCache option:
if ('serviceWorker' in navigator) {
navigator.serviceWorker.register('/service-worker.js', {
updateViaCache: 'none'
});
}
When set to 'none', the HTTP cache will not be consulted when making requests for either the top-level /service-worker.js or for any imported scripted, such as the hypothetical path/to/import.js.
It's actually the filesize difference in the SW file itself. If you would look at this SW example at line 31, the variable CACHE_VERSION gets updated everytime there is an update. This will enable the browser to dump the old one and get a new version from the server.
I have the Play! application running as a windows service. It is implemented according to this guidance.
The problem is that the RUNNING_PID at the root folder of the application is not removed when the server is restarted and the application cannot start again. I have to remove this file and start the service again manually.
Is there any option to solve it?
YAJSW
In case of YAJSW I found this answer with better understanding. It's of course pretty similar to link you gave, anyway keep in mind that it's more often advised to use dist command instead of stage as it has got better developers attention (more bugs fixed in dist). And Mikhail's answer is just clearer (vote him up!)
RUNNING_PID
In case of RUNNING_PID, there was some pull requests which suggested to add an option of disabling pidfile... anyway as I can see, none of them was accepted still...
Actually if you can't avoid creating it, you can... remove it right after application's start, preferably with Globals object's onStart() method. To stay informed what is current PID of the working instance, just rename the file to something, which won't be checked by Play at the startup - for an example RUNNING_PID_INFO. In such case after server's restart service will run your application without problems.
import play.GlobalSettings;
import java.io.File;
public class Global extends GlobalSettings {
#Override
public void onStart(Application application) {
File pidFile = new File("RUNNING_PID");
pidFile.renameTo(new File("RUNNING_PID_INFO"));
}
#Override
public void onStop(Application application) {
File pidFile = new File("RUNNING_PID_INFO");
pidFile.delete();
}
}
(note: changing pidfile.path in apllication.conf will NOT solve the problem, as play will use that for checking if instance is working).
Since Play Framework 2.1 you can disable the PID file by setting the pidfile.path property:
Windows:
-Dpidfile.path=NUL
Unix:
-Dpidfile.path=/dev/null
Found at https://groups.google.com/forum/#!topic/play-framework/4amD9o37Ki4
I recently installed a play framework app using YAJSW by following this answer. I noticed that now, RUNNING_PID is automatically deleted and you don't have to worry about modifying your code to delete the file. Also, if your service depends on other services, it is better to set DELAYED_AUTO_START as the start mode to ensure the service is properly started after server reboot.
I have an ASP.NET-MVC project where I need to dynamically generate some png images. That's easy. I just create ActionResult that returns FileSreamResult object. To generate images I used classes from System.Drawing such as Bitmap and Image. Everything works fine on local machine and on production server. But when IIS on production server shuts down my application pool due to inactivity and starts it again, image generation starts to fail.
Problem was in code that tries to save image to the stream:
var imageStream = new MemoryStream();
bmp.Save(imageStream, ImageFormat.Png);
Exception is: System.Runtime.InteropServices.ExternalException (0x80004005): A generic error occurred in GDI+. So there is no much help. I tried a different solutions and nothing helps. After I have found this topic Alternatives to System.Drawing for use with ASP.NET?
The main idea of this topic is:
Classes within the System.Drawing namespace are not supported for use within a Windows or ASP.NET service. Attempting to use these classes from within one of these application types may produce unexpected problems, such as diminished service performance and run-time exceptions.
So I decided to use WPF classes to generate images. I rewrote all image generation code, but now I get another error after app pool restart. Exception:
System.Runtime.InteropServices.COMException (0x88982F8A): Exception from HRESULT: 0x88982F8A. This happens when I try to save my PngBitmapEncoder to stream
var stream = new MemoryStream();
encoder.Save(stream);
Maybe anyone encountered this problem or just have any ideas?
Here's an unsatisfactory answer...
I was getting the same error when I first deployed my new image generation functionality.
I stopped the corresponding application pool, restarted it again, and it worked.
I cant answer your question as such but if this only occurs because your app shuts down, why not set its Idle to 0 (app pool -> App -> Advanced Options ), then it wont shut down.
It may be a last resort if you cant get a suitable answer.
I am in the process of evaluating several service frameworks and one of them is OpenRasta.
Despite being taken a bit aback for the lack of organization (multiple source code repositories, lack of binary downloads, outdated build instructions and the end result of the build, OpenRasta.dll, has version 0.0.0.0 after building the openrasta-core repository), I managed my way to start building a site with a service that serves a bit of Xml (I did include OpenRasta.Hosting.AspNet and configured the handlers and modules as per IIS or Cassini).
But the very first time I hit the site (both IIS Express and VS Dev Server) I get a ArgumentNullException coming from the PipelineStage.cs. Apparently the pipeline.CallGraph property is null.
My configuration source is a mere:
ResourceSpace.Has
.ResourcesOfType<CatalogCollection>()
.AtUri("/catalogs")
.HandledBy<CatalogsHandler>()
.AsXmlDataContract();
As I mentioned I am using the code I cloned from the openrasta-core repository as of yesterday.
Thanks in advance
try wrapping resource registrations in
using (OpenRastaConfiguration.Manual)
{
//code
}
Also check this out;
https://github.com/openrasta/openrasta-stable/wiki/Building-Your-First-OpenRasta-Website
Hope this helps
I have a windows service that is failing to start, giving an error "Error 1053: The service did not respond to the start or control request in a timely fashion".
Running the service in my debugger works fine, and if I double click on the the service .exe on the remote machine a console window pops up and continues to run without problem - I can even see log messages showing me that the program is processing everything the way it should be.
The service had been running fine previously, though this is my first time, personally, trying to deploy it with the most recent changes made to the program. I've evaluated those changes and cant figure out how they might cause this problem, particuarly since everything runs fine when not started as a service.
The StartRoutine() method of the service impelmentation is empty, so should be returning in a "timely fashion".
I've checked the event logs on the computer, and it doesn't give any additional information other than it didn't hear back from the service in the 30 second requisite time frame.
Since it works on my machine, and as a double-clicked executable, how would I go about figuring out why it fails as a service?
Oh, and it's .NET 2.0, so it shouldn't be affected by the 1.1 framework bug that exhibited this symptom (http://support.microsoft.com/kb/839174)
The box is a windows server 2003 R2 machine running SP2.
This is a misleading error. It's probably an unhandled exception.
Empty your OnStart() handler then try this in your constructor...
public MainService()
{
InitializeComponent();
try
{
// All your initialization code goes here.
// For instance, my exception was caused by the lack of registry permissions
;
}
catch (Exception ex)
{
EventLog.WriteEntry("Application", ex.ToString(), EventLogEntryType.Error);
}
}
Now check the EventLog on your system for your Application Error.
Could be a number of things and it might help to get a stack trace on the machine exhibiting the problem. There are a number of ways to do this but the point is that you have to see where this is failing in the code.
You can do this with remote debugging, but a simple thing might be to just log to the event logger, or file log if you have that. Literally, putting "WriteLine("At class::function()") throughout portions of the code to see if you've made it there.
This will at least get you looking in the right direction (which ultimately is the code).
Update:
See Microsoft's How to Debug Windows Services article for details in troubleshooting startup problems using WinDbg.
This related question details nice ways to debug services that are written in .NET.
I agree with Scott, the easiest way to find out what's happening is to put some traces in the start-up code (maybe it doesn't even come to your start-up code).
If this doesn't help, you can post your code here so others can take a look.
perhaps lacking some dependence, try this :
- deregister your service
- register again
If fail at register means that lack an module.
If the StartRoutine is empty, you are probably starting it somewhere else.
IIRC you need to fire off a worker thread, and then return from StartRoutine.
One of the problems which may lead to this error is if windows service which needs to be deployed consists of some error i.e it may be simple authorization error or anything as in my case I have referenced some folders and files for logging which were not existing, but when provided the right path of those file and folders it solved my problem.
I ran through every post on this particular subject and none of the responses solved the problem, so I'm adding this response in case this helps someone else. Admittedly this only applies to a new service, not this specific case.
I was writing a File listening service. As a console app, it worked perfectly. When I ran it as a service, I got the same error as above. What I didn't know (and many of the MSDN articles about services conveniently leave out) is that you need to have your class executed from within ServiceBase.Run( YourClassName());. Otherwise, your app executes and immediately terminates and because it terminated, you get the error above even if no error or exception occurred. Here is a link to an article about this. It actually discusses setting up your app for dual use - Console app and service: Create a combo command line / Windows service app
I had that issue and the source of my problem was config file. I edited it in notepad and notepad added one special character which cause service not to run properly because config file was ruined. I saw that special character in notepadd++ and after delete it, service started to run successfully as previous did.
In my case, the correct .NET framework was not installed on the server that I was installing the Windows service on.
One other reason is If you copy the DLL in 'debug' mode to installation folder this issue will come.What you need to do is Run the project in 'Release' mode copy the DLL or directly form Release folder rather than Debug folder,,and copy that DLL in to installation folder,it will work.You can see the reduction in size of DLL ,it will not contain any debug symbols and like that