Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7949335
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T01:58:05+00:00 2026-06-04T01:58:05+00:00

I have simple shared memory DLL for interprocess data exchange from unmanaged to managed

  • 0

I have simple shared memory DLL for interprocess data exchange from unmanaged to managed app.
And I noticed that my managed app memory is growing in size steadily.
Can someone advise what can be the cause, how to find it and how to fix it?
Relevant parts of codes below.

cpp SharedMem.DLL:

#pragma data_seg( ".IPC" )
....
double darr[MAXITEMS] = { 0.0 } ; 
....
#pragma data_seg()
....
double __stdcall MGetDouble (int idx)
{
    if ( idx>= 0 && idx < MAXITEMS)
    {
        return darr[idx]; 
    }
    else
    {
        return -1.0 ; 
    }
}

int __stdcall MSetDouble (int idx, double dvalue)
{
    if ( idx>= 0 && idx< MAXITEMS)
    {
        darr[idx] = dvalue;
        return idx;
    }
    else
    {
        return -1;
    }
}

and c# app:

[DllImport("SharedMem.DLL", CallingConvention = CallingConvention.StdCall)]
public static extern double MGetDouble(int index);

....

private void timer1_Tick(object sender, EventArgs e)
{
    ThreadPool.QueueUserWorkItem(dosmth);
}

public object lockobj = new object();

public void dosmth(object o)
{
    if (Monitor.TryEnter(lockobj, 50))
    {
        ....
        double[,] matrix = new double[size, TSIZE];
        ....
        double gvd;
        int k;
        for (int i = 0; i < lines; i++)
            for (j = 0; j < TSIZE; j++) 
            {
                k++; //k can be up to 2k-4k typically
                gvd = MGetDouble(k);
                matrix[i, j] = gvd;
            }
            //... do the stuff
         Monitor.Exit(lockobj);        
     }

}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T01:58:07+00:00Added an answer on June 4, 2026 at 1:58 am

    Try this aproach:

    public class doSmthClass()
    {
        public void doSmthfromClass(...
    }
    

    and alter your “outer” do smth:

    public void dosmth(object o)
    {
      :
      var myInstance = new doSmthClass();
      myInstance.doSmthFromClass();
      :
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have simple SSIS package which reads data from flat file and insert into
I have simple SSIS package where I import data from flat file into SQL
I have a shared memory pool from which many different threads may request an
I was implementing some simple Producer/Consumer program that had some semaphores and shared memory.
I have a very simple class that opens a file and creates a memory
It's a simple app that takes 30 pics from my Resources folder, puts them
I have created a simple linux 32bit shared library(.so) for my rendering wrappers but
I have simple win service, that executes few tasks periodically. How should I pass
I have simple WinForms application where modifying Windows Registry. The problem is that in
I have a simple webpage that serves as an introduction to a more complex

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.