.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

Memory Management issue while calling COM method from .Net component

Posted By:      Posted Date: September 02, 2010    Points: 0   Category :.NET Framework
Hi all,  The Com Component Method say(GetChildresponse) requires Byte pointer as input. From .Net Component, while calling GetChildResponse  I am creating IntPtr and passing it to Component.  I am only creating the pointer in my .Net Component but allocation of bytes(CoTaskMemAlloc) happens at COM Method. After populating the pointer buffer, I am transferring to memory buffer in .Net method and Free the memorry of the pointer using "Marshal.FreeCoTaskMem" method.  Still I am not sure, whether it is deallocating the memory since the Garbarge collector wont happen immediately.  We are hitting on performance issue while doing load testing and we suspect this might be due to memory allocation that is not getting deallocated properly. Any pointers would be helpful. Thanks, Nithya Sample Code: unsafe {   // Get the physical memory address ocpHeaderBufferPointer = new IntPtr((void*)&ocpHeaderBufferPointer); temporaryResponseBufferPointer = new IntPtr((void*)&temporaryResponseBufferPointer); }   try {   try {   // Call the GetResponse of the pass through ocpChannel   new OCPChannelDSClass().GetResponse((uint)transactionId, ocpHeaderBufferPointer, out ocpHeaderBufferSize, temporaryResponseBufferPointer, out temporaryResponseBufferSize, (uint)timeout); }   catch (Exception ex) { &nbs

View Complete Post

More Related Resource Links

Basic Instincts: Objects and Values, Part 2: Memory Management


In the June 2002 installment of Basic Instincts I began a discus-sion of objects and values. This month I'll build on that column, so I will assume you've read the June installment and that you know the fundamental differences between value types and reference types.

Ted Pattison

MSDN Magazine October 2002

Garbage Collection-Part 2: Automatic Memory Management in the Microsoft .NET Framework


The first part of this two-part article explained how the garbage collection algorithm works, how resources can clean up properly when the garbage collector decides to free a resource's memory, and how to force an object to clean up when it is freed. The conclusion of this series explains strong and weak object references that help to manage memory for large objects, as well as object generations and how they improve performance. In addition, the use of methods and properties for controlling garbage collection, resources for monitoring collection performance, and garbage collection for multithreaded applications are covered.

Jeffrey Richter

MSDN Magazine December 2000

Garbage Collection: Automatic Memory Management in the Microsoft .NET Framework


Garbage collection in the Microsoft .NET common language runtime environment completely absolves the developer from tracking memory usage and knowing when to free memory. However, you'll want to understand how it works. Part 1 of this two-part article on .NET garbage collection explains how resources are allocated and managed, then gives a detailed step-by-step description of how the garbage collection algorithm works. Also discussed are the way resources can clean up properly when the garbage collector decides to free a resource's memory and how to force an object to clean up when it is freed.

Jeffrey Richter

MSDN Magazine November 2000

Custom controls and ViewState management issue



I want to know that when we create custom controls, then is there State Management through ViewState done automatically or we have to handle it explicitely ?Since i have created Custom Controls that is behaving as if it is not maintaining its state on PostBack.

Calling parameterized method from aspx file


Hi all,
I have following method
 public string GetYoutubeVideo (string code)
        return "asasdasfa"

calling WCF service Method in HTTP GET by browser or ASP.NET ( like HttpWebRequest for example)

Can i call a WCF service Method using HTTP GET by browser or ASP.NET (without WCF Client)? it can be done with asmx web service.... but i can't find a way to call a WCF service Method with HTTP GET through the browser or C# ASP.NET Code... can i do that ?

SQL Server Management Studio - Invalid access to memory location

In SQL Server Management Studio (for SQL Server 2008), when I try to open a new query window, or create a new database, I get a popup error box saying the following: "Invalid access to memory location. (Exception from HRESULT: 0x800703E6) (mscorlib)" This just started happening in the last few days, and I have no idea why.  I even uninstalled SQL Server 2008, and then installed SQL Server 2008 R2, and continued to get the exact same error, in the exact same scenarios. Please let me know if you have seen this before, and what I might try to correct it. Thanks, Robert  

Usercontrol, in master page, calling a method on the main page?

I have user control called 'Header.asxc' that is registered in my master page. That user control has an image link. The clicking of this link needs to cause a dropdown on the main page to repopulate. I am comforable with delegatges, with populating the dropdown etc... My problem is I cant find the usercontrol from the page, in order to set the function event. I got this work previously when the user control was registered on the page in question but this case with the master page  has me confused. Here is a summary of the set up. 1. I put this in the Header.ascx usercontrol that is registered by the Master page. public Delegate locReloadCompanyDropdown;2. Further down in that page in the relevent _Click event, I put this. locReloadCompanyDropdown.DynamicInvoke();3. Back in the main page I declared these.. public delegate void reloadCompanies(); private event reloadCompanies doReloadCompanies;4. Finally I try to set the delegate doReloadCompanies += new reloadCompanies(PopulateCompanyDropdown); //Page.Header.locReloadCompanyDropdown = doReloadCompanies; //Header.locReloadCompanyDropdown = doReloadCompanies;You can see a couple of attempts I have made remarked out in the code above. Neither work. What am I missing here? Thanks all.  

Calling a method with a class object as parameter data type.

   [WebMethod]    public string GetInfo(Customer inCust)    {        // Code in here    } I have a web service that resides on a remote server. I want to call a public method of theweb service named  "GetInfo". The method is shown above. The web service method expects a class object oftype "Customer". What I did to create a Customer object was to define in my asp.net project my own class named "Customer" which is exactlythe same as the class that belongs to the web service project on the remote server. I then created an instance of Customerand tried to call the web service passing in an object of type customer : my.Service ws = new my.Service(); // Get web service connectionCustomer aCustomer = new Customer();aCustomer.Initialize();ws.GetInfo(aCustomer) // call web service passing in a Customer object The problem is that the compiler gives me the following error: Value of type '_Default.Customer' cannot be converted to 'ws.Class1'. Here Default is refering to my Default.aspx.cs code. Why is this? Do I need to Cast my "aCustomer" class object to a type ofws.Customer ? How do I do that?

Legal issue: How to modify a component?

I know how make it from technical side but I want to make it in the legal way. So the trouble is. We have one component from Microsoft, say PropertyGrid. But this component hasn't enough functionality for us. The legal way (which I know) to change it is inheritance but the functions which I need to override is not marked as virtual and some needed data members are private. The easy way to change it - change some access modifiers direct in PropertyGrid source code but we have only reference source code which we are not allowed to change. I don’t want to describe more technical details because in my mind it is general trouble with Microsoft components which lead us to buy third party components with source code.   Could you show me other way?

Calling a public method on aspx page from a usercontrol

Hello, I have a problem with calling a method on a aspx page from a usercontrol. The case is:I have 1 main page with 5 usercontrols, when something goes wrong in the code I want to display the error message in a Modalpopup Extender.I can create for each usercontrol a different modalpopup extender but isn't much easier when I make 1 popup in the aspx page.But the problem is: How should I call a method in the aspx page that open the popup? I have search several hours on the internet but can't find anything useful. Thanks,  

Issue with new controller method added

I have created an ASP.NET MVC 2 web application that runs beautifull, not a massively complex application, only 2 controllers (Home and Treatment). I have an XML data store that holds page data to be displayed for each of a set of treatments.All pages display exactly as I want them to.I have now added a new controller method for the Treatment controller with the associated XML data and it displays fine in my development environment (displays exactly as I would expect).When I deploy the new XML data and the new TreatmentController.cs file to the new site the link becomes available, but when navigated to I get a 404 page not found exception. All existing links work absolutely fine as they should.The code below shows a working controller method and the controller method that gives the 404 exception, which is pretty much identical, apart from the method and parameter names.public ActionResult Gift_Vouchers(){    GetMasterData(ViewData);    GetTreatmentData("Gift_Vouchers");    return View("Treatment");}//The above method workspublic ActionResult First_Aid_Training(){    GetMasterData(ViewData);     GetTreatmentData("First_Aid_Training");     return View("Treatment");}//The above works in dev environment, fails in liveI would assume that this is something

Viewstate issue when calling button click event from Javascript

I have a javascript that asks a confirmation on search click. If the user has made some changes to the data in grid (gridview) on click of Search, a confirmation is asked to Save or Continue Search. If Yes, Save the records by invoking Save click from javascript. If No, Search click is invoked. While Search click happens correctly, Save click results in an error which reads like this..  "Validation of viewstate MAC failed. If this application is hosted by a Web Farm or cluster, ensure that <machineKey> configuration specifies the same validationKey and validation algorithm. AutoGenerate cannot be used in a cluster. " I know the Viewstate is what causing the problem, where the control is not loaded but script is trying to invoke it's click event. Any help is appreciated. At the end of the day, all i need is to invoke Save click from javascript.   -- Viswanth VG  

Transaction Log Management issue

I'm trying to load A LOT of data to a table, -- about 64million records.  The load process itself will take hours to run and every time I tried it, I got "log is full" error.  I've set the max size to 80G now for the transaction log.  I also scheduled a job to run every 10 mins to shrink the log file.  But it doesn't help at all.  Here are my questions: 1. how to estimate the max size of the log file?  I don't want it to grow unlimited. 2. how to keep the log file as small as possible during the load process?  It'll be the best to me if it can be turned off.  Because I don't need the transaction log at all.   Please help.  It's pretty urgent as I'm very frustrated because of this log issue.  I've tried many times, and the job failed every time.  I'm getting nowhere. Thanks.

sql 2000 Ent memory issue

sql 2000 ent frequently get insufficient memory error when backing up on tlog or do a bulk import, even now increased to 8GB from original 2GB. After restart sql server service, then able to run bulk import, noticed buffer increased around 260MB. of cause tlog can be backup too after sql restart. Don't have any clue now, can someone give some advice or hint? OS is w2k3 Ent 32bit.  

Calling a Web Service Method Asynchronously does not work in Console Application

I have a web service that has a CreateReport method that generates a report based on the specified criteria. When I call this method Synchronously using a Windows Application or Console Application, the call works fine and the report is created. When I call this method ASynchronously (CreateReportASync) using Windows Application the report is created. When I call this method ASynchronously (CreateReportASync) using Console Application the web service does not even get the call.  I am using VS2005 and .Net Framework 2.0.  So the proxy is automatically created with the Async methods.  I am not really interested the result of the method call, so I do not add a Callback Delegate.  

Cascading Dropdown Web Method Issue



I am having an intersting issue to which I have found no solution, obviously. I am using a web service to populate a couple cascading drop downs. Evereything looks correct to me but I am getting a [Method Error 500] when I run it all. I have the <System.Web.Script.Services.ScriptService()> added to the web service so that's not the problem. What I have found while playing with it is that if I remove the arguments from the web method (ByVal knownCategoryValues As String, ByVal category As String) then it works. This of course is not helpful as I am trying to populate multiple drop downs. I can find nothing on anyone else having this issue.

I am using .NET 3.5 and Ajax DLL version 3.02... 

Also of note is that I have another website, using the same .NET and Ajax versions and this code is working fine.

I have tried everything I can think of, including my last resort tactic of smashing my face on my keyboard, and nothing is working. I am at a loss. Any help would be appriciated. Thanks.

Drop Downs:

<asp:DropDownList runat="server" ID="ddlPlateType" Width="250px" />

<ajax:CascadingDropDown runat="server" ID="cddPlateType" TargetControlID="ddlPlateType"
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend