473,486 Members | 2,270 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Attempted to read or write protected memory = memory leak?

4 New Member
Hello,
i have a question on my mind.

Iam developing application which uses twain layer to scan images. So far everything worked fine, but today while testing i got Attempted to read or write protected memory error.

Basicly what i do:
- set capabilities via imported dll calls of twain.dll
- call acquire call via imported dll calls of twain.dll

i get back IntPtr on the data from scanner, which i convert to bitmap by creating empty bitmap and filling bitmap with pixel data. Then i flip newly created bitmap.

At last mentioned i get sometimes error "Attempted to read or write protected memory".

Strange is that its not always, sometimes i takes 200 pages sometimes 400 pages to scan. For test purposes i used 50 papers, and for other test 1 page picture in kodak twain simulator. So its obvious that the problem is not caused by picture data. I forgot to say that i did scan 40 - 50 pages at batch a than repeated the batch.

What i dont understand is why is it happening, since memory of the picture is allocated by twain driver and not me. (EDIT: That is true, but bitmap iam creating from the twain data is created by me..)

Is it possible that the data are somehow locked by unmanaged memory manager??
Or its more likely that there is leaking memory and so all the unmanaged memory is somehow corupted?

I started with NETMasters code here: http://www.codeproject.com/kb/dotnet/twaindotnet.aspx. Dll calls where used without changes.

Any suggestions will be appreciated.
May 17 '10 #1
0 1611

Sign in to post your reply or Sign up for a free account.

Similar topics

9
21305
by: hiralparikh | last post by:
Hi, I am using .NET 2.0 and trying to use a function from a native DLL file. Here is the syntax that I am using: definition: public static extern String getPwd(String strServerName, String...
4
7266
by: Seok Bee | last post by:
Dear Experts, I have created a script to extract the Event Logs from the system into an excel sheet. The logs are separated into 2 worksheets (Application Log and System Log). After this excel...
2
2008
by: humbleaptience | last post by:
I have a web application that uses a DLL using DLLImport. Twice I have put the application live on the net and it has been used hundreds or thousands of time before it has been strangely brought...
2
2395
by: Let_Me_Be | last post by:
Hi, I'm curently developing an aplication which gets called many times, and shoudl return a new state each time, I have implemented load/save state to work with istream/ostream. The problem is...
2
21938
by: Ilkka | last post by:
I have created an C++ application with Windows Forms, ADO and SQL server 2005. Now I need to change something and started debugging the code. Then suddenly I receive an error. "An unhandled...
2
4146
by: Pieter | last post by:
Hi, Since 10 days (the first time was the 10th of november) I have some weird exception happening in an application here: All (except 1 of the total of 5) users had this error now 1 of 2 times...
2
20671
by: adypoly | last post by:
Hi guys... I am having a typical problem in using one of the native dll in C# I'll explain what am trying to do, I've a dll written in C language which i am trying to include in my C# project,...
1
4566
by: rafaelcho | last post by:
Hello I am new to group, and new to development. I have question. I am doing project on embedded, need to read/write to the registers of the microprocessor. Two questions: 1. How to declare?...
6
49874
by: Sugandh Jain | last post by:
Hi, I am getting the error message Attempted to read or write protected memory. This is often an indication that other memory is corrupt. It was not coming until yet, for around 2 months. Now,...
3
6900
by: sriram347 | last post by:
Hi I am a newbie to ASP.NET. I developed a web page (project type is web application) and I keep getting this error. B]Error message : "System.AccessViolation Exception attempted to read or...
0
7099
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
6964
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7319
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5430
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4864
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3070
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1378
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
598
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
262
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.