'ASP.NET core high memory consume

I have some ASP.NET core project and I was looking on memory that consumes. I just get terrified by it. It's not a that big project. I have a few controllers and it consumes about 350MB of Ram and that's a big amount of memory for the webserver.

My question is can I somehow reduce it? One idea that I have is to you struct instead of a model for Data Relation Model, but that will not reduce that that mutch as I want to. Are some other ways, I like to try them all :)

And the last thing, I now ASP.NET core is a very complex framework, that means I wont to use it for small Project this is just for education purposes. and last question: is the memory big problem?

Screenshot of my project: Screenshot 1

my bigger controller :)

using System.Linq;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using RustWiki.Data;
using RustWiki.Models.WikiViewModels;

namespace RustWiki.Controllers.api
{
[Produces("application/json")]
public class TableManagerController : Controller
{
    private readonly ApplicationDbContext _context;
    public TableManagerController(ApplicationDbContext context)
    {
        _context = context;
    }

    protected override void Dispose(bool disposing)
    {
        _context.Dispose();
        base.Dispose(disposing);
    }

    //Get
    [HttpGet]
    [Route("/api/ArmorTypes")]
    public IActionResult GetArmorTypes() => Ok(_context.ArmorTypes.ToList());

    [HttpGet]
    [Route("/api/Cloating")]
    public IActionResult GetCloating() => Ok(_context.Cloating.Include(c => c.ArmorType).Include(c => c.Defencis).Include(c => c.Item.ItemType).ToList());

    [HttpGet]
    [Route("/api/Defencis")]
    public IActionResult GetDefences() => Ok(_context.Defencis.ToList());

    [HttpGet]
    [Route("/api/Dmgs")]
    public IActionResult GetDmg() => Ok(_context.Dmgs.ToList());

    [HttpGet]
    [Route("/api/Equipment")]
    public IActionResult GetEquipment() => Ok(_context.Equipment.Include(e => e.Dmg).Include(e => e.Item.ItemType).ToList());

    [HttpGet]
    [Route("/api/Items")]
    public IActionResult GetItems() => Ok(_context.Items.Include(i => i.ItemType).ToList());

    [HttpGet]
    [Route("/api/ItemTypes")]
    public IActionResult GetItemType() => Ok(_context.ItemTypes.ToList());

    [HttpGet]
    [Route("/api/Resources")]
    public IActionResult GetResource() => Ok(_context.Resources.ToList());

    //Delete

    [HttpDelete]
    [Route("/api/ArmourTypes/{id}")]
    public IActionResult DelArmourType(int id) => Delete(_context.ArmorTypes, id);

    [HttpDelete]
    [Route("/api/Cloating/{id}")]
    public IActionResult DelCloating(int id) => Delete(_context.Cloating, id);

    [HttpDelete]
    [Route("/api/Defences/{id}")]
    public IActionResult DelDefencis(int id) => Delete(_context.Defencis, id);

    [HttpDelete]
    [Route("/api/Dmgs/{id}")]
    public IActionResult DelDmg(int id) => Delete(_context.Dmgs, id);

    [HttpDelete]
    [Route("/api/Equipments/{id}")]
    public IActionResult DelEquipment(int id) => Delete(_context.Equipment, id);

    [HttpDelete]
    [Route("/api/Items/{id}")]
    public IActionResult DelItem(int id) => Delete(_context.Items, id);

    [HttpDelete]
    [Route("/api/ItemTypes/{id}")]
    public IActionResult DelItemType(int id) => Delete(_context.ItemTypes, id);

    [HttpDelete]
    [Route("/api/Resources/{id}")]
    public IActionResult DelResource(int id) => Delete(_context.Resources, id);

    private IActionResult Delete<T>(DbSet<T> set, int id) where T : class
    {
        var obj = set.SingleOrDefault(delegate (T o)
        {
            return (o as IWikiModel)?.Id == id;
        });
        if (obj == null)
            return NotFound();
        set.Remove(obj);
        _context.SaveChanges();
        return Ok(obj);
    }

    //Create

    [HttpPost]
    [Route("/api/ArmourType")]
    public IActionResult CreateArmourType([FromBody]ArmorType type)
    {
        return Ok();
    }
}    
}

Thanks for all the answers.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source