Skip to content

Marshal.FreeHGlobal(x.weight); causes unknown error #8

Description

@MonsterMMORPG

Hello. I am trying to use weights for each class. When i call

 double[] testResults = testSet.Predict(model);

The error happens inside SVMModel.Free(ptr_model);

    public static double[] Predict(this SVMProblem problem, SVMModel model)
    {
        IntPtr ptr_model = SVMModel.Allocate(model);
        double[] target = problem.X.Select(x => x.Predict(ptr_model)).ToArray();
        SVMModel.Free(ptr_model);
        return target;
    }

inside

  SVMModel.Free(x);

inside

SVMParameter.Free(x.param);

It causes error at this function

    public static void Free(svm_parameter x)
    {
        Marshal.FreeHGlobal(x.weight);
        x.weight = IntPtr.Zero;

        Marshal.FreeHGlobal(x.weight_label);
        x.weight_label = IntPtr.Zero;
    }

The error giving line is :

   Marshal.FreeHGlobal(x.weight);

Even in debug mode i don't get any particular error.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions