Created
November 4, 2011 15:46
-
-
Save dagvl/1339646 to your computer and use it in GitHub Desktop.
Minimal example that shows memory issues
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Runtime.Serialization; | |
using System.Threading; | |
using Funq; | |
using ServiceStack.ServiceHost; | |
using ServiceStack.ServiceInterface; | |
using ServiceStack.WebHost.Endpoints; | |
namespace MemLeakTest | |
{ | |
[DataContract] | |
[RestService("/f", Verbs = "POST")] | |
class FileDto { } | |
class AppHost : AppHostHttpListenerBase | |
{ | |
public AppHost() | |
: base("Test memleak", typeof(FileService).Assembly) { } | |
public override void Configure(Container container) | |
{ | |
container.Register(new FileService()); | |
} | |
} | |
class FileService : RestServiceBase<FileDto> | |
{ | |
public override object OnPost(FileDto request) | |
{ | |
return new FileDto(); | |
} | |
} | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
var from = DateTime.Now; | |
var appHost = new AppHost(); | |
appHost.Init(); | |
appHost.Start("http://*:7546/"); | |
while (true) | |
{ | |
var to = DateTime.Now; | |
var time = to - from; | |
//Console.Write("\rMem used: {0} mb ", GC.GetTotalMemory(false) / (1024 * 1024)); | |
Console.Write("{0} {1}\n", time.TotalSeconds, GC.GetTotalMemory(false)); | |
Thread.Sleep(500); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment