Originally posted by: CplexUser
Hi,
I tried to solve an integer programming model "again and again" (iteratively) with each iteration having some different parameters. It always works across hundreds of iterations if the problem is small (no memory leak since I didn't see the memory accumulation across hundreds of iterations) and also works for the first iteration when problem becomes large (3GB to 6GB). However, the second iteration mostly won't work for large problem (same size problem as the first iteration). When it doesn't work, the model will stop at the CpxCreatprob(env, status, "") and show error message of "Attempted to read or write protected memory. This is often an indication that other memory is corrupt". At this point when I check the value of "env", it shows a negative value (not quite sure whether this represents protected memory). The way I declare the cplex lib and write the code is like:
Declare Function CPXopenCPLEX Lib "C:\ilog\CPLEX121\bin\x64_win64\CPLEX121.dll" _
(ByRef status_p_ As Integer) As Integer
Declare Function CPXcreateprob Lib "C:\ilog\CPLEX121\bin\x64_win64\CPLEX121.dll" _
(ByVal env_ As Integer, _
ByRef status_p_ As Integer, _
ByRef probname_str_ As String) As Integer
Dim status As Integer
Dim env As Integer
Dim lp As Integer
env = cplex64.CPXopenCPLEX(status)
lp = cplex64.CPXcreateprob(env, status, "run" & irun) status = cplex64.CPXnewcols(env, lp, countnumColumns_last, obj, lb, ub, cctype, colname)
I have tried this model in at least three 64bits windows computers (one windows 2003 server, one windows XP and one windows 7) and all have the same problem.
I am using VB.net + cplex 12.1 callable library.
This problem has been bugging me for months. Could anybody help give some hints? The detailed error is:
**************************
System.AccessViolationException was unhandled
Message="Attempted to read or write protected memory. This is often an indication that other memory is corrupt."
Source="StochasticFM"
StackTrace:
at StochasticFM.cplex64.CPXcreateprob(Int32 env_, Int32& status_p_, String& probname_str_) at StochasticFM.CPLEXmatrix_Ctype_Result.BuildCPLEXenvi_64() in C:\Tom\StochasticFM\CPLEXmatrix_and_Ctype.vb:line 793 at StochasticFM.frmMainInput.Button1_Click(Object sender, EventArgs e) in C:\Tom\StochasticFM\frmMainInput.vb:line 339 at System.Windows.Forms.Control.OnClick(EventArgs e) at System.Windows.Forms.Button.WndProc(Message& m) at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m) at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam) at System.Windows.Forms.UnsafeNativeMethods.SendMessage(HandleRef hWnd, Int32 msg, IntPtr wParam, IntPtr lParam) at System.Windows.Forms.Control.SendMessage(Int32 msg, IntPtr wparam, IntPtr lparam) at System.Windows.Forms.Control.ReflectMessageInternal(IntPtr hWnd, Message& m) at System.Windows.Forms.Control.WmCommand(Message& m) at System.Windows.Forms.Control.WndProc(Message& m) at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m) at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam) at System.Windows.Forms.UnsafeNativeMethods.CallWindowProc(IntPtr wndProc, IntPtr hWnd, Int32 msg, IntPtr wParam, IntPtr lParam) at System.Windows.Forms.NativeWindow.DefWndProc(Message& m) at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks) at System.Windows.Forms.Control.WndProc(Message& m) at System.Windows.Forms.ButtonBase.WndProc(Message& m) at System.Windows.Forms.Button.WndProc(Message& m) at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m) at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam) at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg) at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData) at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context) at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context) at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun() at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel() at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(Stringhttp://] commandLine) at StochasticFM.My.MyApplication.Main(String
Args) in 17d14f5c-a337-4978-8281-53493378c1071.vb:line 81 at System.AppDomain._nExecuteAssembly(Assembly assembly, String[ args) at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly() at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) at System.Threading.ThreadHelper.ThreadStart()
InnerException:
#CPLEXOptimizers#DecisionOptimization